Program-6
Generate a random number between 1 and 10. Ask the user to guess the
number and print a message based on whether they get it right or not.
import random n=random.randint(1,10)
Guessnumber=int(input("Enter a Number
Between 1 to 10:"))
print("Random Number is=",n)
if(n==Guessnumber):
print("Your Guess is Right")
else:
print("Your Guess is Wrong")
Output:
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32
bit (Intel)] on win32 Type "help", "copyright", "credits" or "license()" for
more information. >>> ======== RESTART: D:/old/r19 lab-python/5.py =========
Enter a Number Between 1 to 10:5
Random Number is= 4
Your Guess is Wrong
>>>
===== RESTART: D:/old/r19 lab-python/5.py
=========
Enter a Number Between 1 to 10:8
Random Number is= 5
Your
Guess is Wrong
>>>
No comments:
Post a Comment