Python - Guessing Game
- Due Oct 18, 2016 by 11:59pm
- Points 8
- Submitting a file upload
- File Types pdf
Questions: Assignment Discussion: Python - Guessing Game
Note: This assignment is due on Tuesday night!
Create a guessing game using Python. Create one file for all of the questions below (separate them with comments, as I did in the FineganSolution.py file). Print that file to a PDF and submit in this assignment.
Start your file by declaring a correct answer as a string, e.g. correctAnswer = "8" (use a number between 0 and 9). Use python's input to get an answer from the user and store their input in a variable. Please make sure to test your code before submitting it. Some good inputs to test for each question are the following: the correct answer, 0, 9, "a", as well as some incorrect/high/low guesses in the 0-9 range.
1. Compare their input to the correct answer, report if correct or not, then finish.
2. Compare their input and report whether the guess was high or low, then finish.
3. Use while to allow the user to update their input; only finish when they get their guess correct.
(optional) 4. Add code that allows the user to quit at any time by typing either q or Q.
5. Test with a number above 9 (e.g., 10!). What behavior do you see? Change your declaration of correctAnswer to correctAnswer = 8 (i.e., without the quotes). In a comment provide a description of how the behavior of your code changes? Why? How did you go about understanding what was happening? What resources were useful, what did you understand or not understand when seeking the answer?
Rubric
Criteria | Ratings | Pts | |||
---|---|---|---|---|---|
Q1
Code runs, and conforms to the specifications of the homework. The variables are named accordingly.
threshold:
pts
|
|
pts
--
|
|||
Q2
Code runs, takes input, and conforms to the specifications of the homework. Half credit if code runs but breaks on certain input, or runs but does not return the correct direction. Check for what happens when the guess is correct!
threshold:
pts
|
|
pts
--
|
|||
Q3
Code runs, accepts input, and informs the user whether their guess is high or low or correct. The code runs until the user provides correct input. Make sure to use "while."
threshold:
pts
|
|
pts
--
|
|||
Q4 (Optional)
Code fits the specifications of Q3, and additionally allows an input of q or Q from the user to end it. Both q and Q should end the script.
threshold:
pts
|
|
pts
--
|
|||
Q5
Code does what the Q4 code does, but uses 8 instead of "8" for correctAnswer. No credit if there is no comment explaining your reasoning for the open-ended questions.
threshold:
pts
|
|
pts
--
|
|||
Total Points:
8
out of 8
|