A program that generates numbers between 1 and 100….

$22.00

Category:

Description

Design a  well-documented Python program that:

·      Generates a random number between 1 and 100.

·      Allows the user 10 tries to guess what the number is.

·      Validates the user input (if user-input >100 or user-input<0) then this is invalid input and should not cost the user to lose any tries.

·      Gives feedback for each time the user makes a guess. The feedback tells the user whether the number entered is bigger, smaller, or equal to the number generated (and exits the program).

·      Tells the user if they lost after he/she consumes all the 10 tries. Gives the user 10 tries to guess the number. If the user exhausts the 10 ties. The user loses.

Now, this is a very typical program. But we will add a twist to it. After 2 unsuccessful tries, the program should start offering hints for the users (by having the user input the number 0).

·      Each hint should be generated within a function of its own.

·      Each hint will cost the user two tries (the program should indicate this to the user)

·      The user is allowed a max of 3 hints only.

·      The program should randomly pick which hint it is going to use and display to the user.

The hints are of your choice, but here are a couple (feel free to introduce others):

1-        The number is bigger than or equal the square of some X (X is an integer and is the largest integer square that is less than the user input)

2-   The number is smaller than or equal the square of some K (K is an integer and is the smallest integer square that is larger than the user input)

3-      The number is a multiple of some Y (Y is an integer)

4-      The number is even or odd

5-      The number is one digit

This is an example of program execution. Red is user input

Welcome to our game. Guess a number between 1 and 100. You have 10 tires

Try 1: What is the number ?

50

Guess smaller

Try 2: What is the number ?

25

Guess smaller

Try 3: What is the number ? Need a hint? Enter the number 0 for that hint!

0

The number is bigger than or equal the square of 4

Try 5: What is the number ? Need a hint? Enter the number 0 for that hint!

0

The number is smaller than or equal the square of 5

Try 7: What is the number ? Need a hint? Enter the number 0 for that hint!

0

The number is odd

Try 9: What is the number ?

19

Guess smaller

Try 10: What is the number ?

17

You got it!

·       The user has used all of the hints, hence, the program should not display the hint choice again!

·       Make sure the hints start after the second try

·       If the user inputs the number 0 in the first or second try. It should not trigger the hint.