Question: Using for or while loops mainly! Python! question 2: 1. Play Guess my number. Your program should choose a secret number, a positive integer up



1. Play "Guess my number." Your program should choose a "secret number", a positive integer up to 10,000. The user tries to guess that number. After each guess, the program tells the user whether their guess was too high, or too low, or if they've guessed the secret number. The user should be able to continue guessing until either they guess the secret number right, or they enter 0 to stop playing. Normally, we would have the program select a random number as the secret number. However, for the purpose of testing your program (and grading it), simply use an assignment statement to set the secret number to 1458. Here is a sample run of the program: I'm thinking of a number from 1 to 10000. Try to guess my number! (Enter 0 to stop playing.) Please enter your guess: You can assume that the user will enter an integer as a guess; however, your program must verify that each guess is either: O in which case the program should print "Goodbye" and end. Goodbye! . Or be between 1 - 10000 (inclusive). If it is not, it should print the following message and re-prompt the user: Your guess must be between 1 to 10000. Please enter your guess: If the user has entered a correct guess, your program should print the message: That's correct! You win! You guessed my number in X guesses. where X is the number of tries the user took. Your program should then terminate. If the user's guess is low, your program should print the message: Your guess is too low. If the user's guess is high, your program should print the message: Your guess is too high. If the guess is too high or too low, it should then prompt the user to guess again: Please enter your gues: Expected output: This is what your output might look like if the user guessed the number in four tries: I'm thinking of a number from 1 to 10000. Try to guess my number! (Enter 0 to stop playing.) Please enter your guess: 5000 Your guess is too high. Please enter your guess: 1000 Your guess is too low Please enter your guess: 12000 Your guess must be between 1 to 10000. Please enter your guess: 1458 That's correct! You win! You guessed my number in 4 guesses. This is what your output might look like if the user quit playing: I'm thinking of a number from 1 to 10000. Try to guess my numbert (Enter 0 to stop playing.) Please enter your guess: 5000 Your guess is too high. Please enter your guess: 1000 Your guess is too low. Please enter your guess: 0 Goodbyo! 2. Ask the user to hit enter before moving on to question 2. You can use this line of code: input("Hit enter to draw a pyramid.") Print out the following pyramid, using only loops. (Do not use string multiplication!) * ** *** **** ** Here is the loop again, with spaces indicated by dashes. You will not actually print out the dashes - this is just to help you see how many spaces there are on each line. * .** *** **** 3. Draw the following picture using turtle graphics and loops. There are 10 rows and 7 columns
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
