100-Days OF Python-Day-04

 Things to learn from this today are Randomisation,list:


 import random
random_integer=range(random.randint(1,10))
print(random_integer)

random_float=random.random(0,5)
print(random_float)

WAP for Head & Tail if we do not have a coin:
import random
coin_toss=random.randint(0,1)
if coin_toss==0:
    print("Head")
else:
    print("Tail")

##Programming is like an open book test and its all about critical thinking.

WAP to predict who is going to pay the bill:
import random
name_string=input("Give me everybody's names, separated by a comma.")
names=name_string.split(",")
print(names)
random_number=random.randint(0,3)

bill_person=(names[random_number])
print(f"{bill_person} is going to buy the meal today")

WAP Treasure Hidding game:
row1 = ["⬜️","⬜️","⬜️"]
row2 = ["⬜️","⬜️","⬜️"]
row3 = ["⬜️","⬜️","⬜️"]
map = [row1, row2, row3]
print(f"{row1}\n{row2}\n{row3}")
position = input("Where do you want to put the treasure? ")
column_p=int(position[0])
row_p=int(position[1])
print(column_p)
print(row_p)
selected_row=map[(row_p)-1]
selected_row[column_p-1]="x"
print(f"{row1}\n{row2}\n{row3}")

Project Of Day-04
Rock Paper Scissor Game

print("Lets Play Game:")
import random
object_list=["rock","paper","scissors"]
user_input=(input("Lets chose one number from 0,1,2: "))
user_input1=int(user_input)
print(f"{user_input} User input")
machine_input=random.randint(0,2)
print(f"{machine_input} Machine input")
user_result=object_list[user_input1]
machine_result=object_list[machine_input]
if user_result=="rock" and machine_result=="scissors":
    print("You win,computer loss")
elif user_result=="rock" and machine_result=="paper":
    print("You lose computer wins")
elif user_result=="paper" and machine_result=="scissors":
    print("You lose,computer wins")


The above program needs correction Just consider logic only


Comments

Popular posts from this blog

Top 5 Best Books For Python,Data Science & Machine Learning

How To Start A BLOG

Top 50 Most Innovative Companies in 2020

Why Should We learn C Programming?

Blogger Tutorial