0

Program that picks random numbers and user guesses in python

I want to build an app that picks random number automatically from 1 to 10 or 1 to 20 and let the user guess. if guess is right, it awards the user with points. I can write a few lines but the part that makes the app pick random numbers is the problem and also to award point is the problem. this is not a professional job, I just want the code for learning sake. thanks

15th Mar 2018, 9:05 PM
Tarrmie de Man
Tarrmie de Man - avatar
11 ответов
+ 9
Here's the random part, I hope you can figure out what's what: import random real_value = random.randint(1, 20) print(real_value)
15th Mar 2018, 9:21 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 7
Np. Try it on your own and experiment with it. Later write here if you have any further questions, we'll answer them ;)
15th Mar 2018, 9:28 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
15th Mar 2018, 10:10 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 7
Did you input all inputs needed? for ex, if the input is in a loop, it needs an input for every time it goes thru the loop
17th Mar 2018, 4:58 PM
J.G.
J.G. - avatar
+ 6
If you want a limit of a given number of trials, you can put the input part inside a for loop and break it if the answer is correct. If you want to ask until guessed, you should use a while loop, instead.
15th Mar 2018, 10:00 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 3
@tarrmie That's most likely becuz you didn't input. Eof is end of file (I think), so whatever program it was was looking for an input and it did not get one
15th Mar 2018, 10:36 PM
J.G.
J.G. - avatar
+ 1
Your answer was helpful. I want to also add maximum trials before it prints the correct number. I already have this import random real_value = random.randint(1, 10) guess = int(input("pick number\n")) print(guess) if (guess ==real_value): print("You guessed right:\n Congratulation!!!") else: print("wrong\ncorrect number is:\n", real_value
15th Mar 2018, 9:52 PM
Tarrmie de Man
Tarrmie de Man - avatar
0
thanks..
15th Mar 2018, 9:26 PM
Tarrmie de Man
Tarrmie de Man - avatar
0
can you give a code
15th Mar 2018, 10:00 PM
Tarrmie de Man
Tarrmie de Man - avatar
0
"got EOF error when reading the line"
15th Mar 2018, 10:16 PM
Tarrmie de Man
Tarrmie de Man - avatar
0
I did
17th Mar 2018, 12:10 PM
Tarrmie de Man
Tarrmie de Man - avatar