Using Random Module:
CODE:
1. Game for children
import random
count=3
ans='y'
win=False
print("guess what number computer generated between 20-30")
print("Total 3 chances are there")
print("___________________________________________________________")
while ans=='y':
num1=[Link](20,30)
print("change remaining:", count)
guess=int(input("Enter your answer: "))
if num1==guess:
print("Congratulations!, you guessed it right")
win=True
else:
print("wrong!")
count-=1
if count==0:
print("oops!, you lost all your chances")
print("number was:",num1)
if win==True or count==0:
ans==input("play again?")
if ans=='y':
count=3
win=False
OUTPUT:
guess what number computer generated between 20-30
Total 3 chances are there
___________________________________________________________
change remaining: 3
wrong!
change remaining: 2
wrong!
change remaining: 1
wrong!
oops!, you lost all your chances
number was: 30
change remaining: 3
wrong!
change remaining: 2
wrong!
change remaining: 1
wrong!
oops!, you lost all your chances
number was: 26
change remaining: 3
Congratulations!, you guessed it right
2.
import random
a=[Link]()
print(a)