HW 3: Python Part 2 HW 3: Python Part 2 Copy the starter code Create a new repl for this homework. Click here to access the starter code (click on the Code tab), copy it, and paste it into that new...

1 answer below »
https://docs.google.com/document/d/1KQUljhC3ihtCLfpGfzT3g9gpD4DuYAESn8Ud3kt5oQI/edit


HW 3: Python Part 2 HW 3: Python Part 2 Copy the starter code Create a new repl for this homework. Click here to access the starter code (click on the Code tab), copy it, and paste it into that new repl in your account. Don’t change any of the provided code. What your Python program should do (in plain English) You will create a program that will try to guess a number that the user is thinking of between 1 and 20. The program should accept input from the user as to whether the guess was too high or too low, and change the next guess accordingly. The program starts by guessing a random number between 1 and 20. This has been done for you. 1. Tell the user what number the computer guessed. 2. Ask the user to enter “h” if the guess was too high, “l” (lowercase L) if the guess was too low, or “c” if the guess was correct. All letters are lowercase and without quotes. 3. If the guess was correct, print a funny congratulations message and exit the program. 4. If the guess was too high, subtract from the guess a random number between 1 and 4. Use this new number as the next guess. a. Note: it’s possible that doing this will result in a guess that’s below 0, which doesn’t make sense. Add some code to check if the new guess is below 0, and if it is, set the new guess equal to 1. 5. If the guess was too low, add to the guess a random number between 1 and 4. a. Here, it doesn’t make sense to have a guess above 20. Add some code to check if the new guess is above 20, and if it is, set the new guess equal to 20. Tell the user each new guess and let the user continue providing input. The program should run until the user enters “c” (no quotes), signaling the end of the game. https://repl.it/@bus101/Starter-code-guessing-game-reversed Important grading note Any submission that your TA feels is coded to guess every number in some sort of order, e.g., 1, 2, 3, 4 … 20, will receive an automatic maximum score of 35 out of 50. The difficulty in this homework is in designing simple logic that is similar to how a human would play a guessing game where the computer thinks of a random number for the human to guess. You will work with this logic in your discussion activity for this week. Python resource How to generate a random number: https://www.w3schools.com/python/ref_random_randint.asp Sample output All output is from multiple runs of the program. The program only needs to run once (e.g., one full round of guessing until correct) at a time. # I’m thinking of the number 10. Think of a number in your head and the computer will try to guess it! Once you see the guess, you can tell the computer if the guess was too high, too low, or correct. The computer guesses 11. Enter h if the guess was too high. Enter l if the guess was too low. Enter c if the guess was correct. h The computer guesses 7. Enter h if the guess was too high. Enter l if the guess was too low. Enter c if the guess was correct. l The computer guesses 8. Enter h if the guess was too high. Enter l if the guess was too low. Enter c if the guess was correct. l The computer guesses 11. Enter h if the guess was too high. Enter l if the guess was too low. Enter c if the guess was correct. h The computer guesses 7. Enter h if the guess was too high. https://www.w3schools.com/python/ref_random_randint.asp Enter l if the guess was too low. Enter c if the guess was correct. l The computer guesses 10. Enter h if the guess was too high. Enter l if the guess was too low. Enter c if the guess was correct. c Nice work! ? # I’m thinking of the number 20. Think of a number in your head and the computer will try to guess it! Once you see the guess, you can tell the computer if the guess was too high, too low, or correct. The computer guesses 5. Enter h if the guess was too high. Enter l if the guess was too low. Enter c if the guess was correct. l The computer guesses 7. Enter h if the guess was too high. Enter l if the guess was too low. Enter c if the guess was correct. l The computer guesses 10. Enter h if the guess was too high. Enter l if the guess was too low. Enter c if the guess was correct. l The computer guesses 12. Enter h if the guess was too high. Enter l if the guess was too low. Enter c if the guess was correct. l The computer guesses 13. Enter h if the guess was too high. Enter l if the guess was too low. Enter c if the guess was correct. l The computer guesses 14. Enter h if the guess was too high. Enter l if the guess was too low. Enter c if the guess was correct. l The computer guesses 16. Enter h if the guess was too high. Enter l if the guess was too low. Enter c if the guess was correct. l The computer guesses 18. Enter h if the guess was too high. Enter l if the guess was too low. Enter c if the guess was correct. l The computer guesses 20. Enter h if the guess was too high. Enter l if the guess was too low. Enter c if the guess was correct. c Nice work! ? How to submit your Python code When you are done with your code, click into your browser’s address bar and copy that entire link. Create a new text submission in iLearn. Paste your link into the text box (not the comments box) and submit. Grading rubric 50 points total. To grade your program, your TA will pick a number and play the game for real. If you code your program with appropriate logic (see “Important grading note” above) and your program can correctly guess the number, you will earn 50 points. If your program is coded appropriately but cannot guess the correct number, you will earn 45 out of 50 points. If you “cheat” the logic by brute force guessing every number, you will earn an automatic 35 out of 50 points. If you make a solid effort but can’t get your program to run, you will earn 30 out of 50 points. Blank files will earn a 0. Invalid submission links will receive a penalty as noted in the syllabus.
Answered Same DayOct 26, 2021

Answer To: HW 3: Python Part 2 HW 3: Python Part 2 Copy the starter code Create a new repl for this homework....

Aditya answered on Oct 27 2021
128 Votes
import random
computerGuess = random.randint(1,20)
print("Think of a number in your head and the c
omputer will try to guess it!")
print("Once you see the guess, you can tell the computer if the guess was")
print("too high, too low, or correct.\n")
while True:
print("The computer...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here