Python Problem 6 | Python Tutorials For Absolute Beginners In Hindi #113

Guess The number

Generate a random integer from a to b. You and your friend have to guess a number between two numbers a and b. a and b are inputs taken from the user. Your friend is player 1 and plays first. He will have to keep choosing the number and your program must tell whether the number is greater than the actual number or less than the actual number. Log the number of trials it took your friend to arrive at the number. You play the same game and then the person with minimum number of trials wins!

Randomly generate a number after taking a and b as input and don’t show that to the user (say 6)

Input:

Enter the value of a

4

Enter the value of b

13

Output:

Player1 :

Please guess the number between 4 and 13

5

Wrong guess a greater number again

8

Wrong guess a smaller number again

6

Correct you took 3 trials to guess the number

Player 2:

.

.

.

Correct you took 7 trials to guess the number

Player 1 wins!


►Full Python tutorials for absolute beginners (Hindi) playlist - https://www.youtube.com/playlist?list=PLu0W_9lII9agICnT8t4iYVSZ3eykIAOME
►Click here to subscribe - https://www.youtube.com/channel/UCeVMnSShP_Iviwkknt83cww


Be the first person to comment!

Comments(0)