Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Describe your program here. You must describe your program 3 . Write a Python program that asks the user to enter a number between 1
Describe your program here. You must describe your program
Write a Python program that asks the user to enter a number between and inclusive.
Make sure the number entered by the user is in the given range. If the userentered number is not in the range,
display an appropriate message to the user and repeatedly ask the user to enter a number in the range.
If the number is in the range but not equal to a computergenerated random number, assist the user by telling them
to guess higher or lower three times including the first attempt.
If the user did not win on the third attempt, display a message based on the following criteria.
random number user number; they win $ in lottery.
random number user number ; they win $ in lottery.
random number user number ; they win $ in lottery.
random number user number ; they win $ in lottery.
random number user number ; they win $ in lottery.
random number user number ; You didn't win; please try again.
Allow the user to play again as much as they like.
Input:
Enter a number between and to win lottery: a
Output:
Your input is invalid.
Enter a number between and to win lottery:
Input:
Enter a number between and to win lottery:
Output:
You entered a number out of range.
Enter a number between and to win lottery:
Output:
You won amount in lottery.
Do you wish to play the game again? y or n:
or
Sorry, You did not win; please try again.
Do you wish to play the game again? y or n:
Use must use variables such as choice, usernumber, amount, randomnumber, etc.
Hint: You will need to validate the usernumber.
import random
import math
choice y
# Write your code below this line
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started