View the step-by-step solution to:

Question

# a program that will generate a secret random number from 0 to 20, and which gives the user 4 tries to guess the

number. After each incorrect guess your program should tell the user if the secret number is higher or lower than their guess. After 4 guesses the program should tell the user the correct number and exit. If the user is able to guess the secret number the program should tell them that they won.

Here's what two sample runs of the program might look like:

Guess 1: 10

Higher

Guess 2: 15

Lower

Guess 3: 13

Lower

Guess 4: 12

You lost, the number was 11.

The code is given below... View the full answer

if flag:
print ( 'You won')
else:
print (' You lost, the number was' , computer)
Guess 1: 8
Higher
Guess 2: 9
Higher
Guess 3: 12
Lower
Guess 4: 11
You won

### Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

• ### -

Study Documents

Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

Browse Documents