Guess The Number | Game | Python Program

Guessing number :

Tips:

1.Import random, use it.
2.Take user given range.
3.Take user given number.
4.Use if and else. 

Code:

import random

x=int(input('Enter the range: '))

a=random.randint(1,x)

print('your range is 1 to ',x,'\n')

while(1):

    n=int(input('Enter your choice: '))

    if(n!=a):

        print('you lose!')

        if(n>a):

            print('your value is high')

        else:

            print('your value is low')

    else:

        print('you win!')

        break

Output:




If you love this program or any question comment.Visit again.



Comments

Post a Comment

Give your feedback!
DO NOT SPAM !!
NO THIRD PARTY PROMOTIONAL LINK !!!! (else comment will be deleted.)

Popular posts from this blog

TOP 10 PROGRAMMING LANGAUAGES COMMING 2021 | ARTICLE

Write a C-program to swap two number:

Print Fibonacci Series using Recursion | C program :