Advertisement
Guest User

the_riddler.py

a guest
Jan 23rd, 2020
450
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.80 KB | None | 0 0
  1. #!/usr/bin/python3
  2.  
  3. # The Riddler by t0p 2020
  4.  
  5. import random
  6. from os import system
  7.  
  8. choices = []
  9.  
  10. riddles = {
  11. 0:["""I speak without a mouth and hear without ears.
  12. I have no body, but I come alive with wind. What am I?""", ("echo",), False],
  13. 1:["""You measure my life in hours and I serve you by expiring.
  14. I’m quick when I’m thin and slow when I’m fat. The wind is my enemy.
  15. What am I?""", ("candle",), False],
  16. 2:["""What is seen in the middle of March and April that can’t be seen
  17. at the beginning or end of either month?""", ("r", "letter r", "the letter r"), False],
  18. 3:["What disappears when you say its name?", ("silence",), False],
  19. 4:["""I have keys, but no locks and space, and no rooms.
  20. You can enter, but you can’t go outside. What am I?""", ("keyboard",), False],
  21. 5:["What gets wetter the more it dries?", ("towel",), False],
  22. 6:["Which word in the dictionary is always spelled incorrectly?", ("incorrectly",), False],
  23. 7:["""What comes once in a minute, twice in a moment,
  24. but never in a hundred thousand years?""", ("m", "letter m", "the letter m"), False],
  25. 8:["The more you take, the more you leave behind. What am I?", ("footsteps", "steps", "footprints"), False],
  26. 9:["""I am not alive, but I grow; I don't have lungs, but I need air;
  27. I don't have a mouth, but water kills me. What am I?""", ("fire",), False],
  28. 10:["What do you need to break before you use it?", ("egg",), False],
  29. 11:["""You have me today,
  30.    Tomorrow you'll have more;
  31.    As your time passes,
  32.    I'm not easy to store;
  33.    I don't take up space,
  34.    But I'm only in one place;
  35.    I am what you saw,
  36.    But not what you see.
  37.  
  38.    What am I?""", ("memories",), False],
  39. 12:["""They have not flesh, nor feathers, nor scales, nor bone.
  40. Yet they have fingers and thumbs of their own.
  41.  
  42. What are they?""", ("gloves",), False],
  43. 13:["""This is as light as a feather, yet no man can hold it for five minutes.
  44. What am I?""", ("breath", "your breath", "my breath"), False],
  45. 14:["Poor people have it. Rich people need it. If you eat it you die. what is it?", ("nothing",), False],
  46. 15:["The more you take away, the bigger I become. What am I?", ("hole", "a hole"), False],
  47. 16:["""Always in you, Sometimes on you;
  48.    If I surround you, I can kill you.
  49.  
  50.    What am I?""", ("water",), False],
  51. 17:["I am full of holes but I can still hold water. What am I?", ("sponge", "a sponge"), False],
  52. 18:["I can be cracked, I can be made. I can be told, I can be played. What am I?", ("joke", "a joke"), False],
  53. 19:["What can travel around the world without leaving its corner?", ("stamp", "a stamp"), False],
  54. 20:["Look in my face, I am somebody; Look in my back, I am nobody. What am I?", ("mirror", "a mirror"), False],
  55. 21:["What can you keep only after you have given it?", ("word", "your word", "my word"), False],
  56. 22:["""I follow you all the time and copy your every move,
  57. but you can’t touch me or catch me. What am I?""", ("shadow", "your shadow", "my shadow"), False],
  58. 23:["What goes up and down but doesn’t move?", ("stairs", "staircase"), False],
  59. 24:["What has words, but never speaks, has leaves but doesn't grow?", ("book", "a book"), False],
  60. 25:["What runs all around a backyard, yet never moves?", ("fence", "a fence", "wall", "a wall"), False],
  61. 26:["""I am an odd number. Take away a letter and I become even.
  62. What number am I?""", ("7", "seven"), False],
  63. 27:["I ask no questions but demand to be answered nevertheless.  Who am I?", ("phone", "telephone"), False],
  64. 28:["What five-letter word becomes shorter when you add two letters to it?", ("short",), False],
  65. 29:["What begins with an 'e' and only contains one letter?", ("envelope", "an envelope"), False],
  66. 30:["""A word I know, six letters it contains, remove one letter and 12 remains.
  67. What is it?""", ("dozens",), False],
  68. 31:["""I am the beginning of everything, the end of everywhere.
  69. I’m the beginning of eternity, the end of time and space. What am I?""", ("e", "letter e", "the letter e"), False],
  70. 32:["Forward I am heavy, but backward I am not. What am I?", ("ton", "word 'ton'", "the word 'ton'"), False],
  71. 33:["I am a word of letters three; add two and fewer there will be. What word am I?", ("few",), False],
  72. 34:["What word of five letters has one left when two are removed?", ("stone",), False],
  73. 35:["What word is pronounced the same if you take away four of its five letters?", ("queue",), False],
  74. 36:["What can run but never walks, has a mouth but never talks, has a head but never weeps, has a bed but never sleeps?", ("river", "a river"), False],
  75. 37:["If you drop me I’m sure to crack, but give me a smile and I’ll always smile back. What am I?", ("mirror", "a mirror"), False],
  76. 38:["I turn once, what is out will not get in. I turn again, what is in will not get out. What am I?", ("key", "a key"), False],
  77. 39:["People make me, save me, change me, raise me. What am I?", ("money",), False],
  78. 40:["What can be measured but not seen?", ("time",), False],
  79. 41:["I occur twice in eternity but I'm always in sight.  What am I?", ("t", "letter t", "the letter t"), False],
  80. 42:["""Someone makes it, but has no need of it. Someone buys it,
  81. but has no use for it. Someone uses it, but can neither see nor feel it.
  82. What is it?""", ("coffin", "a coffin"), False],
  83. 43:["""The eight of us go forth, not back,
  84. To protect our king from a foe's attack. What are we?""", ("pawns", "chess pawns", "pawn"), False]
  85. }
  86.  
  87. def clear():
  88.     _ = system('clear')
  89.  
  90. def choose_riddles():
  91.     while len(choices) < 10:
  92.         num = random.randint(0, len(riddles) - 1)
  93.         if num not in choices:
  94.             choices.append(num)
  95.            
  96. def play_game():
  97.     clear()
  98.     print("""
  99. _____ _           ______ _     _     _ _          
  100. |_   _| |          | ___ (_)   | |   | | |          
  101.  | | | |__   ___  | |_/ /_  __| | __| | | ___ _ __
  102.  | | | '_ \ / _ \ |    /| |/ _` |/ _` | |/ _ \ '__|
  103.  | | | | | |  __/ | |\ \| | (_| | (_| | |  __/ |  
  104.  \_/ |_| |_|\___| \_| \_|_|\__,_|\__,_|_|\___|_|  
  105.                                                    \n\n""")
  106.     score = 0
  107.     choose_riddles()
  108.     for turn in choices:
  109.         answer = input(str(riddles[turn][0] + "\n> "))
  110.         if answer.lower() in riddles[turn][1]:
  111.             print("\nCorrect\n")
  112.             score += 1
  113.         else:
  114.             print("\nIncorrect\n")
  115.     print_results(score)
  116.        
  117. def print_results(score):
  118.     if score == 10:
  119.         prestring = "Congratulations! "
  120.     elif score in (8, 9):
  121.         prestring = "Okay! "
  122.     elif 4 < score < 8:
  123.         prestring = "Not bad!"
  124.     elif score in (3, 4):
  125.         prestring = "Ah. "
  126.     else:
  127.         prestring = "Oh dear… "
  128.        
  129.     print(prestring + "You scored %d out of 10." % score)
  130.    
  131. def play_again():
  132.     # returns True or False
  133.     while True:
  134.         answer = input("Do you want to play again? (Y/n) > ")
  135.         if answer.lower() in ("y", "yes"):
  136.             return True
  137.         else:
  138.             return False
  139.  
  140. def main():
  141.     while True:
  142.         play_game()
  143.         if not play_again():
  144.             return
  145.    
  146. if __name__ == '__main__':
  147.     main()
  148.     exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement