Answered step by step
Verified Expert Solution
Link Copied!

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
3. Write a Python program that asks the user to enter a number between 100 and 500 inclusive.
Make sure the number entered by the user is in the given range. If the user-entered 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 computer-generated 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 $10,000 in lottery.
-> random number - user number <100; they win $7,000 in lottery.
-> random number - user number <200; they win $5,000 in lottery.
-> random number - user number <300; they win $3,000 in lottery.
-> random number - user number <400; they win $1,000 in lottery.
-> random number - user number >=400; You didn't win; please try again.
Allow the user to play again as much as they like.
Input:
Enter a number between 100 and 500 to win lottery: a
Output:
Your input is invalid.
Enter a number between 100 and 500 to win lottery: 100
Input:
Enter a number between 100 and 500 to win lottery: 50
Output:
You entered a number out of range.
Enter a number between 100 and 500 to win lottery: 100
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, user_number, amount, random_number, etc.
Hint: You will need to validate the user_number.
"""
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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 23rd European Conference Adbis 2019 Bled Slovenia September 8 11 2019 Proceedings Lncs 11695

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Aida Kamisalic Latific

1st Edition

3030287297, 978-3030287290

More Books

Students also viewed these Databases questions

Question

Create a Fishbone diagram with the problem being coal "mine safety

Answered: 1 week ago

Question

List the different categories of international employees. page 642

Answered: 1 week ago

Question

Explain the legal environments impact on labor relations. page 590

Answered: 1 week ago