Python
HW 3
Python Part 2
We’ve learned throughout the class that it’s not about learning the tool, it’s about learning how to think like an IS professional. In our previous assignments, we’ve covered design, data visualization, and data analysis. For our last two assignments, we will work with a very basic technical component. If you are interested in or already pursuing IS, consider this a stepping stone to future classes and career options.
What your Python program should do
Create a new repl for this homework.
Use the starter code from this page: https://repl.it/@mgt205/STARTER-CODE-HW-3
Copy and paste the code into your own repl. You can also click “Fork” and it’ll copy the entire thing into your repl account.
1. Generate a random number between 1 and 20. This has been done for you.
2. Let the user guess the number (assume the user can’t see the printed number).
3. Tell the user if the guess is too high, too low, or correct.
a. If the guess is correct, print a congratulations message (feel free to make it funny) and exit the program.
b. If the guess is incorrect, let the user guess again. The user gets unlimited chances to guess.
How to submit your Python code
If you do not see a “Share” button in the top right, please turn off any ad blockers.
When you are done with your code, click “Share” in the top right. You will see an info box pop up like the screenshot below. At the bottom of the box, click “Copy repl link”. Please do not use the “Invite someone with a join link” feature.
Create a new text submission in iLearn. Paste your link into the text box (not the comments box) and submit.
Note: if you change the title of your repl after submitting, your link will no longer be valid. You will need to create a new link (see steps above) and submit again. I recommend making the title of your repl something simple like “[first name] [last name] HW 3” and leaving it like that.
Sample output
This is the sample output from multiple runs of the program.
First run:
13
Enter a number: 15
Your guess is high!
Enter a number: 10
Your guess is low!
Enter a number: 13
You got it! Hopefully you were guessing and not just looking at the answer above. :)
Second run:
7
Enter a number: 10
Your guess is high!
Enter a number: 10
Your guess is high!
Enter a number: 10
Your guess is high!
Remember that the user has unlimited guesses.
Enter a number: 10
Your guess is high!
Enter a number: 15
Your guess is high!
Enter a number: 20
Your guess is high!
Enter a number: 10
Your guess is high!
Enter a number: 10
Your guess is high!
Enter a number: 10
Your guess is high!
Enter a number: 7
You got it! Hopefully you were guessing and not just looking at the answer above. :)