Write a python program that asks the user to guess a number

Assignment Help Python Programming
Reference no: EM131504893

Assignment: Guess the Number

For this assignment you will be writing a program from scratch! Follow the directions posted below.

Level 1. Write a Python program that asks the user to guess a number between 0 and 100 and give feedback that tells the user the guess was too high or too low until they correctly guess the number.

Level 2. After the user correctly guesses the number, add output telling the user how many guesses it took.

Level 3. The range for guessing changes after each guess. For example if the user's first guess is 50 and the feedback is that the guess was to high, the next guess should be between 0 and 50. To help the user, update the new range for the guess every time they are asked for another guess.

Level 4. What if the user accidentally types a number that is not within then range? Provide feedback that the guess was outside the range and then do not change the range for the guesses when prompted for another guess. Let's also not count a guess outside the range in their total number of guesses.

Level 5. After the user correctly guesses the number, ask if they would like to play again. If the first letter of their response is 'y' or 'Y' start over with a range from 0 to 100 again. Hint: Put your current loop that gets user guesses inside another loop that starts the game over again.

Level 6. Each time the user guesses the correct number include feedback giving the fewest number of guesses needed to correctly guess the number (low/best score). Hint: You can initialize the low score at a really high number like 100 guesses.

Below is an example of the output for this game.
Welcome to Guess the Number!
Please enter your guess between 0 and 100. 50 Too low.
Please enter your guess between 50 and 100. 25 Your guess is not between 50 and 100.
Please enter your guess between 50 and 100. 75 Too low.
Please enter your guess between 75 and 100. 85 Too high.
Please enter your guess between 75 and 85. 80

Congratulations. You guessed the number in 4 guesses! Your low score is 4 guesses.

Would you like to play again? yes
Please enter your guess between 0 and 100. 20 Too high.
Please enter your guess between 0 and 20. 3

Congratulations. You guessed the number in 2 guesses! Your low score is 2 guesses.

Would you like to play again? no

Reference no: EM131504893

Questions Cloud

What is the longest bone in the hid limb muscles : What is the longest bone in the hid limb muscles that work together a junction where bones meet what make up most of the human skeleton
Preferred stock dividends : Preferred stock dividends:
A fully efficient market will eliminate : A fully efficient market will eliminate which one of the following?
What is the present value of annuity payment : What's the present value of a $620 annuity payment over four years if interest rates are 8 percent?
Write a python program that asks the user to guess a number : Write a Python program that asks the user to guess a number between 0 and 100 and give feedback that tells the user the guess was too high or too low until.
Draw the indifference curves between x and y : An extra unit of X adds nothing to a consumer's satisfaction unless accompanied by an extra unit of Y.
Find the height yi from which the rock was launched : Use the value g= 9.800 m/s2 for the free-fall acceleration. Find the height yi from which the rock was launched.
What is the payback period of the project : Conch Republic Electronics is a midsized electronics manufacturer loated in Key West, Florida. What is the payback period of the project?
Create a rectangularprism class that has instance variables : Create a RectangularPrism class that has three instance variables for the three dimensions of a rectangular prism (length, width, and height).

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd