Write a Python program that will allow a user to guess a secret number between 100 and 1000. The secret number is randomly generated by the computer. After the user enters their guess, the program checks the guess against the secret number. If the user guessed the correct number, the program will tell the user they won. If the user didn’t guess the correct number, the program will tell the user if their guess was higher or lower than the secret number and give the user another opportunity to guess. This time the user will either be told they won or lost. If they lost, the secret number should be revealed to the user.
Write a Python program that will allow a user to guess a secret number between 100 and 1000. The secret number is randomly generated by the computer. After the user enters their guess, the program checks the guess against the secret number. If the user guessed the correct number, the program will tell the user they won. If the user didn’t guess the correct number, the program will tell the user if their guess was higher or lower than the secret number and give the user another opportunity to guess. This time the user will either be told they won or lost. If they lost, the secret number should be revealed to the user.
ALGORITHM:-
1. Take input for the number between 100 and 1000 from the user for the first time.
2. Generate a random number between 100 and 1000.
3. If the input number matches the random number tell the user that they have won.
4. If not give them another chance and repeat the process.
5. At end reveal the secret number.
6. Finish.
Step by step
Solved in 4 steps with 2 images