Coding with Loops Worksheet
Print | Save
Output: Your goal
You will complete a program that asks a user to guess a number.

Part 1: Review the Code
Review the code and locate the comments with missing lines (# Fill in missing code). Copy and paste the code into the Python IDLE. Use the IDLE to fill in the missing lines of code.

On the surface this program seems simple. Allow the player to keep guessing until he/she finds the secret number. But stop and think for a moment. You need a loop to keep running until the player gets the right answer.

Some things to think about as you write your loop:

The loop will only run if the comparison is true.
(e.g., 1 < 0 would not run as it is false but 5 != 10 would run as it is true)
What variables will you need to compare?
What comparison operator will you need to use?
# Heading (name, date, and short description) feel free to use multiple lines

def main():

# Initialize variables
numGuesses = 0
userGuess = -1
secretNum = 5

name = input("Hello! What is your name?")

# Fill in the missing LOOP here.
# This loop will need run until the player has guessed the secret number.

userGuess = int(input("Guess a number between 1 and 20: "))

numGuesses = numGuesses + 1

if (userGuess < secretNum):
print("You guessed " + str(userGuess) + ". Too low.")

if (userGuess > secretNum):
print("You guessed " + str(userGuess) + ". Too high.")

# Fill in missing PRINT statement here.
# Print a single message telling the player:
# That he/she guessed the secret number
# What the secret number was
# How many guesses it took

main()
Part 2: Test Your Code
Use the Python IDLE to test the program.
Using comments, type a heading that includes your name, today’s date, and a short description.
Run your program to ensure it is working properly. Fix any errors you observe.
Example of expected output: The output below is an example of the output from the Guess the Number game. Your specific results will vary based on the input you enter.

Output

Your guessed 10. Too high.
Your guessed 1. Too low.
Your guessed 3. Too low.
Good job, Jax! You guessed my number (5) in 3 tries!



When you've completed filling in your program code, save your work by selecting 'Save' in the Python IDLE.

When you submit your assignment, you will attach this Python file separately.

Part 3: Post Mortem Review (PMR)
Using complete sentences, respond to all the questions in the PMR chart.

Review Question Response
What was the purpose of your program?
How could your program be useful in the real world?
What is a problem you ran into, and how did you fix it?
Describe one thing you would do differently the next time you write a program.

Part 4: Save Your Work
Don't forget to save this worksheet. You will submit it for your assessment.

Answers

Answer 1
Mmmmmmmmmmmmmmmmmmmmmmmm
Answer 2
Uhh this is giving me a headache

Related Questions

PLEASE WRITE A ONE SENTANCE SUMMARY, WILL GIVE BRAINLIEST!! (history of computers) You have completed an extensive investigation of the question Who invented the computer? You have gathered sufficient evidence, and the moment has come to report your findings!


Step 1: Write a one-sentence summary of your conclusion to the question Who is the inventor of the computer? Be sure you can back up this claim with evidence in the the remaining activities in this assessment.

Answers

Answer:

Charles Babbage, (born December 26, 1791, London, England—died October 18, 1871, London), English mathematician and inventor who is credited with having conceived the first automatic digital computer.

Explanation:

The idea of mechanically calculating mathematical tables first came to Babbage in 1812 or 1813. Later he made a small calculator that could perform certain mathematical computations to eight decimals. Then in 1823 he obtained government support for the design of a projected machine, the Difference Engine, with a 20-decimal capacity. The Difference Engine was a digital device: it operated on discrete digits rather than smooth quantities, and the digits were decimal (0–9), represented by positions on toothed wheels rather than binary digits (“bits”). When one of the toothed wheels turned from nine to zero, it caused the next wheel to advance one position, carrying the digit. Like modern computers, the Difference Engine had storage—that is, a place where data could be held temporarily for later processing.

Ima comment so the person above me can get a brainliest

Which of these lists correctly orders the binary numbers from smallest to largest?


A: 1010,0110,0101,0011


B: 0011,0110,0101,1010


C: 1010,0101,0110,0011


D: 0011,0101,0110,1010

Answers

Answer:

The answer is D: 0011,0101,0110,1010

D is the correct answer.

Which part of project management takes deadlines into consideration?

Analysis
Resources
Scope
Time

Answers

Resources

enjoy ur day!
Analysis

Have a wonderful day mate :)

Which part of project management takes deadlines into consideration?

Analysis
Resources
Scope
Time

Answers

Time is the answer I guess
Bcz if the deadline date passes and the task is not completed,Project displays an indicator .

Answer:

time

Explanation:

Define the term algorithm and give one example of an algorithm that can be used to solve a problem.

PLZ HELP ME!

Answers

a process or set of rules to be followed in calculations or other problem-solving operations. Example: PEMDAS

Final one bit l y links are a virus that will corrupt your files do not go on it

Answers

That’s actually really helpful, someone answer my question with one but I’m glad I didn’t use the link :)

How to get the pc accelerate pro virus off my computer

Answers

Try to see a computer specialist to help
if that is a type of program, click on windows or search for "control panel" go to programs and right click uninstall on it. hope this works
Other Questions
Rocket engines can be fueled by liquid hydrogen. The liquid hydrogen reacts with liquid oxygen, producing water vapor and releasing an enormous amount of energy.Consider the following reaction:2 molecules of hydrogen (H2) react with 1 molecule of oxygen (O2) to produce some amount of water (H2O).To find the amount of water produced, first determine the number of each type of atom in the products.Hint: During a chemical reaction, atoms are not created, destroyed, or changed from one chemical element to another. Which one of the following sets of ordered pairs determines a line whose slope is 4/3? A. (5,-3)(2,3) B. (3,10) (-3,-2) C. (3,-5) (-3,-7) D. (-1,-3) (5,5 HELP PLEASE ITS MUSIC I WILL MARK BRAINLIEST AHEMMMMMMMMMMM *INHALES*hola estar desperdiciando puntos de nuevo * sorbos de t * um nada inapropiado algunos de ustedes probablemente ya me recuerdan verdad? Oh, bueno, no se permiten enlaces porque se informarn primero, ser ms inteligente, no lo olvides.(hehehehhe * does evil laugh*) Ik yall are greedy for points so I used a translator so you wouldn't see my points whoever is first to translate that statement to english will be marked brainliest yes ik i said who is actually FIRST to answer but, that was just to make it harder WHOEVER CAN TRANSLATE FASTEST AND MOST ACCURATE WILL GET BRAINLIEST and if you don't have to use a translator then LUCKY YOU What is the largest possible number of peopel at a party if no two of them have birthdays in the same month QuiaActive16:05:5A plant root is an example of My teacher didnt explain this. Help me please! Please awnser this correctly! I will make you Brainliest! Liza is building a storage container in her basement.The container will have two sections that are connected.How many cubic foot boxes can she store in the container?Enter your answer in the box.6 ft2 ft6 ft8 ft2 ft6 ft help me with this problem please Directions: Write True if the statement is correct and False if it is notcorrect. Write your answer on the answer sheet.1. Friction is a force that pulls object downward.2. Friction is a force that resists motion.3. We must use extra force to start the motion of stationaryobjects.4. Static friction does not allow an object to move.5. Kinetic energy allows an object to move. what is the error?AUTHORIZED PERSONAL ONLY Two angles are vertical angles. If one angle measures 3x+14, and the other angle measures 5x, find the measure of each angle. 0.006 A= _____ mAhelp me,,,, Use the picture to summarize the difference between the daughter cells that result from mitosis and meiosis.how were cells discovered?Word Bank haploid, diploid Can you pls help me please describe how a reflex action is coordinated by the different parts of the human nervous system Find the measure of 5 Please help! I need this to pass. If you are trying to get points please just chose a different question and don't mess with mine. I am in a state of trouble and I just need a helping hand. an electronic book has a file size of 2.6 MB what is the file size and megabytes of 14 of these electronic books