2nd Semester Intro to Computer Science

Lab 3.01 - Magic 8-Ball

Practice importing random** — Use randint with different arguments. Simulate a dice roll, printing out to the user what number they rolled.

Look at the documentation of the random library — Experiment with another function (not randint) that returns a value.

Create a program that simulates a magic 8-ball

  1. Store all of the 8-ball’s possible responses (shown below) in a list
  2. Have the program prompt the user to ask the magic 8-ball a question
  3. then return and print a random response.

Magic 8-Ball Response Examples

  • Outlook is good
  • Ask again later
  • Yes
  • No
  • Most likely no
  • Most likely yes
  • Maybe
  • Outlook is not good

Video Explanation

Magic 8 Ball

Bonus

Research the math library and create a program that finds the length of the hypotenuse of a right triangle given two sides.

Edit this page Report an issue