Lab cycle6

 

Exercise 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.



Source Code:

import random

sysvalue = random.randint(1,10)

n = int(input("Guess a number between 1 and 10: "))

if (n==sysvalue):

    print("You guess is right.")


else:


print("Sorry! System generated number is",sysvalue)


Result:

Guess a number between 1 and 10: 6

Sorry! System generated number is 5



Comments

Popular posts from this blog

NOTE