CSCI 107 Assignment 5
- Due Date: Friday, October 11th no later than 11:59 p.m.
- Partner Information: You may complete this assignment individually or
with exactly one classmate.
- Submission Instructions (working alone): Upload your solution,
entitled YourFirstName-YourLastName-Assignment5.py
to the BrightSpace Assignment 5 Dropbox.
- Submission Instructions (working with exactly one classmate): Upload your solution, entitled
YourFirstName-YourLastName-PartnerFirstName-PartnerLastName-Assignment5.py
to the BrightSpace Assignment 5 Dropbox. Note: If you work with a
partner, only one person needs to submit a solution. If you both
submit a solution, the submission that will be graded is the one from
the partner whose last name comes alphabetically first.
- Deadline Reminder: Once the submission deadline passes, BrightSpace
will no longer accept your submission and you will no longer be able
to earn credit. Thus, if you are not able to fully complete the
assignment, submit whatever you have before the deadline so that
partial credit can be earned.
Problem: Magic 8 Ball 🎱
For this lab, you will build a 20 sided magic 8-ball.
If you are curious about all the choices, you can read up more on them here.
A standard Magic 8 Ball has twenty possible answers, including ten affirmative answers (🟢), five non-committal answers (🟠), and five negative answers (🔴).
- 🟢 It is certain
- 🟢 It is decidedly so
- 🟢 Without a doubt
- 🟢 Yes definitely
- 🟢 You may rely on it
- 🟢 As I see it, yes
- 🟢 Most likely
- 🟢 Outlook good
- 🟢 Yes
- 🟢 Signs point to yes
- 🟠Reply hazy, try again
- 🟠Ask again later
- 🟠Better not tell you now
- 🟠Cannot predict now
- 🟠Concentrate and ask again
- 🔴 Don't count on it
- 🔴 My reply is no
- 🔴 My sources say no
- 🔴 Outlook not so good
- 🔴 Very doubtful
Since we can't have our user physically shake a magic 8-ball, we will ask them to enter a random number from 1-20 to represent a shake. The answers should line up with the numbers 1-20 following the order they're listed in above.
We will assume that our user can't access this page to try to cheat when using the magic 8-ball program.
Learning Outcomes
- Gain experience with Python selection statements.
- Gain experience with Python functions.
Assignment
- Download magic8ball.py and rename
it according to the instructions above.
- Modify the program by adding the missing code inside the functions with a #TODO comment.
If the functions are
implemented correctly, your output
should look very similar to this image. *Message following "--> Magic 8 Ball says:" will differ depending on the number rolled *
- Do not change any of the code in main()! your functions should call eachother!
Grading - 100 Points
- 10 Points - The missing
get_question
function is implemented properly (prompts user and returns a boolean).
- 10 Points - The missing
get_roll
function is implemented properly (prompts user, validates input, and returns an integer).
- 10 Points - The missing
affirmative_response
function is implemented properly (returns a string response based on the roll).
- 10 Points - The missing
non_committal_response
function is implemented properly (returns a string response based on the roll).
- 10 Points - The missing
negative_response
function is implemented properly (returns a string response based on the roll).
- 20 Points - The missing
shake_8ball
function is implemented properly (selects and returns the appropriate response based on the roll).
- 10 Points - The program handles invalid inputs gracefully in
get_roll
and provides user-friendly error messages.
- 10 Points - The program demonstrates effective use of selection statements to determine responses.
- 10 Points - The solution is of high quality (5 points), appropriate comments are added to your solution, and instructional comments are removed (5 points).
Program Testing
Make sure your program works with all of the twenty possible answers listed in the problem above.