Guess a number from 1 to 50
Task
The computer thinks of a random number from 1 to 50 - generate it with random.randint(1, 50) right at the start of the program, only once. The user guesses, and after each guess the program prints prilis male (too small) or prilis velke (too big) until they get it. Then it prints uhadol si (you got it) and on the next line the number of valid guesses.
Handle the input: if a guess is not a whole number, print zadaj cislo (enter a number); if it is not from 1 to 50, print cislo musi byt od 1 do 50. Such guesses do not count.
During the tests the randomness is "frozen", so the tests know the secret number - you need not worry about it.
Examples
Input
10 40 25
Expected output
prilis male prilis velke uhadol si 3
Input
abc 30 12.5 25
Expected output
zadaj cislo prilis velke zadaj cislo uhadol si 2
Rules
Handle the input with
try/except.The
exceptbranch is missing.
After you submit, 3 hidden tests will also check your solution: numbers outside 1 to 50, guessed at once, closing in step by step.
Python starts the first time you run code.
Ctrl+Enter runs the program. Tab indents. Press Esc, then Tab, to leave the editor.
Input (stdin)
Each line = one call to input().
Output
Hints
Try it yourself first. Each hint reveals a little more - and lowers the reward a little.
Signed out, hints are free - but no XP is awarded either.
Solution
The solution unlocks after the last hint.