How to Create Magic 8-ball in Python

What is Magic 8-ball
 
The Magic 8 Ball is a toy used for fortune-telling or seeking advice, developed in the 1950s and manufactured by Mattel. It is often used in fiction, often for humor related to its giving very accurate, very inaccurate, or otherwise statistically improbable answers.
 
Source:https://en.wikipedia.org/wiki/Magic_8-Ball
 
Code
  1. #import modules  
  2. import sys  
  3. import random  
  4.   
  5. ans1=True  
  6.   
  7. while ans1:  
  8.     que=input("Ask the magic 8 ball a question(1-8) press .(dot) if you want to exit")  
  9.     print("\n")  
  10.       
  11.     anss=random.randint(1,8)  
  12.       
  13.     if que== ".":  
  14.         sys.exit()  
  15.       
  16.     elif anss== 1:  
  17.         print("It is certain")  
  18.       
  19.     elif anss== 2:  
  20.         print("Outlook good")  
  21.       
  22.     elif anss== 3:  
  23.         print("You may rely on it")  
  24.       
  25.     elif anss== 4:  
  26.         print("Ask again later")  
  27.       
  28.     elif anss==5:  
  29.         print("Concentrate and ask again")  
  30.       
  31.     elif anss== 6:  
  32.         print("Reply hazy, try again")  
  33.       
  34.     elif anss== 7:  
  35.         print("My reply is no")  
  36.       
  37.     elif anss== 8:  
  38.         print("My sources say no")  
Output
 
 
Ebook Download
View all
Learn
View all