Advertisement
here2share

# Tk_Missing_Word_Game.py

Sep 6th, 2016
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.39 KB | None | 0 0
  1. # Tk_Missing_Word_Game.py
  2.  
  3. from time import sleep
  4. import random
  5. import os
  6.  
  7. Words = "music drive night smile smart tooth about money clock funny chair price drink focus dance radio watch clean green laugh \
  8. house round amaze beach".split()
  9. how2play = "You will be shown 9 words for 15 seconds. You will then be shown another 9 words and must identify the word that has gone missing."
  10.  
  11. zmode = """To make a selection,
  12. type the number corresponding to the option --
  13.  
  14. 1. Easy mode
  15. 2. Hard mode
  16. 3. Quit
  17.  
  18. >>>>>  """
  19. def menu():
  20.     random.shuffle(Words)
  21.     mnuSelection = raw_input(zmode).strip()
  22.     if mnuSelection == "1":
  23.         easygame()
  24.     elif mnuSelection == "2":
  25.         hardgame()         
  26.     elif mnuSelection == "3":
  27.         return
  28.     else:
  29.         os.system("cls")
  30.         print("Invalid input. Please type only the number corresponding to your selection.\n\n")
  31.         menu()
  32.  
  33. def easygame():
  34.     def splitlines(A)
  35.         print(str(A[0::3]) + "\n" + str(A[1::3]) + "\n" + str(A[2::3]))
  36.         return
  37.     lstWords=Words[:10]
  38.    
  39.     swapindex = random.randint(0,8)
  40.     removedword = lstWords.pop(random.randint(0,9))
  41.     print(how2play)
  42.     sleep(5)
  43.     os.system("cls")
  44.     splitlines(lstWords)
  45.     sleep(15)
  46.    
  47.     os.system("cls")
  48.     sleep(3)
  49.     swappedword = lstWords.pop(-1)
  50.     lstWords.insert(0,removedword)
  51.     random.shuffle(lstWords)
  52.     splitlines(lstWords)
  53.     sleep(3)
  54.  
  55.     plyWord = raw_input("Identify the word that has been swapped.   > ").strip()
  56.     plyword = str.lower(plyWord)
  57.     print
  58.     if plyWord == swappedword:
  59.         print("Congratulations, you answered correctly.")
  60.     else:
  61.         print("You did not guess correctly. The correct answer was "+swappedword+".")
  62.     print
  63.     menu()
  64.    
  65. def hardgame():
  66.     def splitlines(A):
  67.         print(str(A[0::4]) + "\n" + str(A[1::4]) + "\n" + str(A[2::4]) + "\n" + str(A[3::4]))
  68.         return
  69.     lstWords=Words[:17]
  70.     removedword = lstWords.pop(random.randint(0,16))
  71.     print(how2play.replace('9','16'))
  72.     sleep(5)
  73.     os.system("cls")
  74.     splitlines(lstWords)
  75.     sleep(15)
  76.    
  77.     os.system("cls")
  78.     sleep(3)
  79.     swappedword = lstWords.pop(-1)
  80.     lstWords.insert(0,removedword)
  81.     random.shuffle(lstWords)
  82.     splitlines(lstWords)
  83.     sleep(3)
  84.  
  85.     plyWord = raw_input("Identify the word that has been swapped.   > ").strip()
  86.     plyword = str.lower(plyWord)
  87.     print
  88.     if plyWord == swappedword:
  89.         print("Congratulations, you answered correctly.")
  90.     else:
  91.         print("You did not guess correctly. The correct answer was "+"'"+swappedword+"'.")
  92.     print
  93.     menu()
  94. menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement