Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For example, you tell your friend that you are thinking of a number between 0 and 100 and give then five guesses to come up

image text in transcribed
image text in transcribed
image text in transcribed
For example, you tell your friend that you are thinking of a number between 0 and 100 and give then five guesses to come up with it. You do give then a hint consisting of "too high" or "too low" just after they state their guess. Write a Python program which attempts to guess the day of the month you were born. You need to tell the progran how many quesses are allowed and how many days there are in your birth month. The allowable values the days in your birth month are 28,29,30 and 31. If you enter a number 1ike 28, then the program will ask you to txy again to enter a correct number of days. The program then uses the randint function to generate a guess. You need to import the "random" Python library to gain access to randint. When you call randint, you give the function two arguments separated by a comma. So randint (1,30) will generate a random integer between 1 and 30. The program gives back it's randon guess and then you need to respond with a "1" for "your guess is too low", or an "h" meaning that your guess is too "high" or a "c" meaning that the program correctly guessed your day of birth. If the program runs out of guesses (exceeds the number of guesses allowed that you specified) then it prints the fact that it was not successful in guessing your day of birth. Use selection structures ilf, elif, else) as needed. Use a "while" loop to validate the month number entered is in the range of 28 to 31. Use a "for" loop for the quesses. There must be a "break" in the loop when the program fails to guesa your birth date. Case 1: Failure Case (ran out of quesses) : Let's Play Guess Your Birthday! Enter max number quesses alloved:3 nter days in birth month (28,29,30,31):30 Ky gress is: 5 Znter "h" for high, "1" for low, "c" for correct:1 My guess is: 27 " for high, "1" for low, 'c' for correctih Wy guess is: 7 "hor high, "1, for low, 'c' for correctil I failed to guess your birthdayl Case 2: Success Case .. quessed correctly within quesses allowed: Let's Rlay Guess Your Birthday! Rnter max number guesses alloved:10 Enter days in birth month (28,29,30,31):30 My guess is: 20 Bnter 'h' for high, "1' for low, 'c" for correct:h My guess 1 s: 6 Enter 'h' for high, "1. for low, "e' for correct:1 My guess iss 11 Bnter 'h' for high, '1' for low, 'c' for correct:1 My guess ist 14 ' My guess in: 12 Enter 'h' for high, 'I' for lew, 'e' for correctll My guess is: 13 Enter 'h' for high, "I' for low, 'e" for correctio I guessed 13 in 6 guesses? Case 3: User runs out of tries fer correet days in birth month Let's play Guess Your Birthabyt Enter max number guesses alloweda10 Enter days in birch month (2.8,29,30,31):32 Incorrect response, 2 tries left. Enter days in birth month (28,29,30,31):20 Incorrect response. 1 tries left. Bnter days in birch month (26,29,30,31):1 Tries for month days exceeded. Program will assume 30 birth month days (program continues as before having assumed 30 days in month) Lab 3 Check Iist and Grading Points (Rubric) = 10 points total ax 1. Name your file fileprefixlab03.py and include header block as shown (1 points) 4 Name: (your name) - Coursez CS 1160 ) Assignment: Lab 03 t Date Assigned: 1/30/2023 - Filename: fileprefixlab03.py - Brief Description: Guess a Number Game 2. Use meaningfu1 comments in your program. (2 points) 3. Use meaningful variable names. (2 points) 4. Proper use of input, randint, and break (2 points) 5. Correct and clear use of relational. (=, , etc) operators and if-elif-else structures and looping (2 points) 6. Make sure your output is similar to the type of output shown above. You may (and should) do further cases to make sure your program logic is correct (1 points) Outline of code on next page. Additional instructions are in the code outline on how to develop your lab assignment. Bubmit to Dropbox both a py file and txt file of your code. Put sample output at the bottom of your file starting and ending with triple apostrophes

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

Step: 3

blur-text-image

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

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions

Question

Describe how language reflects, builds on, and determines context?

Answered: 1 week ago