Guest User

Untitled

a guest
Feb 18th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. # Making a Magic 8 ball Game
  2. # By Justine Robert Igune
  3.  
  4.  
  5. import unittest
  6. from unittest import TestCase
  7.  
  8. import random
  9. import time
  10.  
  11.  
  12.  
  13. #Sequence for random choice
  14. Magic8Ball_answers = ['It is certain', 'It is decidedly so', 'Without a doubt',
  15. 'Yes – definitely', 'You may rely on it', 'As I see it, yes',
  16. 'Most likely', 'It looks good', 'Yes Signs point to yes',
  17. 'Question not clear', 'try again', 'Ask again later', 'Better not tell you now',
  18. 'Cannot predict now', 'Concentrate and ask again', 'Dont count on it', 'My reply is no',
  19. 'My sources say no', 'It looks not so good', 'Very doubtful']
  20.  
  21. print(' __ __ __ __ __ _____ _____ _____ ___ ')
  22. print(' | | | || | | \/ | /\ / ____|_ _/ ____| / _ \ _ ')
  23. print(' | |____| | | | \ / | / \ | | __ | || | | (_) | |_| ')
  24. print(' | ____ | | | |\/| | / /\ \| | |_ | | || | > _ < _ ')
  25. print(' | | | || | _ | | | |/ ____ \ |__| |_| || |____ | (_) | |_| ')
  26. print(' |__| |__||__| /_/ |_| |_/_/ \_\_____|_____\_____| \___/ ')
  27. print('')
  28. print('')
  29. print('')
  30.  
  31.  
  32. print('Hello There, I am the Magic 8 Ball, What is your name?')
  33. name = input()
  34. print('Hello ' + name + ',')
  35.  
  36.  
  37. #Delay output for 0.5 second each
  38. print("Processing...")
  39. time.sleep(0.5)
  40. print("Wait...")
  41. time.sleep(0.5)
  42. print("Wait...")
  43. time.sleep(0.5)
  44. print("Wait...")
  45. time.sleep(0.5)
  46. print()
  47.  
  48.  
  49. #Generate a random integer/response
  50. response = random.randint(0,20)
  51.  
  52. def Magic8Ball():
  53. print('Feel free to ask your question or Seek an advice please.')
  54. input()
  55. print("In Progress...")
  56. time.sleep(3)
  57. print (Magic8Ball_answers[random.randint(0, len(Magic8Ball_answers)-1)] )#Generate a random integer/response
  58. print('I hope that helped you!')
  59. Replay()
  60.  
  61.  
  62. def Replay():
  63. print ('Do you have another question or still seek advice? [Y/N] ')
  64. reply = input()
  65. print("In Progress...")
  66. time.sleep(3)
  67. if reply == 'Y':
  68. Magic8Ball()
  69. elif reply == 'N':
  70. print("Bye bye, See you again...")
  71. exit(0)
  72. else:
  73. print('I apologise, I did not understand what you meant. Please try again.')
  74. Replay()
  75.  
  76.  
  77. #To import name 'Magic_8_Ball_Game' from 'Magic_8_Ball_Game
  78. Magic8Ball()
Add Comment
Please, Sign In to add comment