Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_Missing_Word_Game.py
- from time import sleep
- import random
- import os
- Words = "music drive night smile smart tooth about money clock funny chair price drink focus dance radio watch clean green laugh \
- house round amaze beach".split()
- 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."
- zmode = """To make a selection,
- type the number corresponding to the option --
- 1. Easy mode
- 2. Hard mode
- 3. Quit
- >>>>> """
- def menu():
- random.shuffle(Words)
- mnuSelection = raw_input(zmode).strip()
- if mnuSelection == "1":
- easygame()
- elif mnuSelection == "2":
- hardgame()
- elif mnuSelection == "3":
- return
- else:
- os.system("cls")
- print("Invalid input. Please type only the number corresponding to your selection.\n\n")
- menu()
- def easygame():
- def splitlines(A):
- print(str(A[0::3]) + "\n" + str(A[1::3]) + "\n" + str(A[2::3]))
- return
- lstWords=Words[:10]
- swapindex = random.randint(0,8)
- removedword = lstWords.pop(random.randint(0,9))
- print(how2play)
- sleep(5)
- os.system("cls")
- splitlines(lstWords)
- sleep(15)
- os.system("cls")
- sleep(3)
- swappedword = lstWords.pop(-1)
- lstWords.insert(0,removedword)
- random.shuffle(lstWords)
- splitlines(lstWords)
- sleep(3)
- plyWord = raw_input("Identify the word that has been swapped. > ").strip()
- plyword = str.lower(plyWord)
- print
- if plyWord == swappedword:
- print("Congratulations, you answered correctly.")
- else:
- print("You did not guess correctly. The correct answer was "+swappedword+".")
- print
- menu()
- def hardgame():
- def splitlines(A):
- print(str(A[0::4]) + "\n" + str(A[1::4]) + "\n" + str(A[2::4]) + "\n" + str(A[3::4]))
- return
- lstWords=Words[:17]
- removedword = lstWords.pop(random.randint(0,16))
- print(how2play.replace('9','16'))
- sleep(5)
- os.system("cls")
- splitlines(lstWords)
- sleep(15)
- os.system("cls")
- sleep(3)
- swappedword = lstWords.pop(-1)
- lstWords.insert(0,removedword)
- random.shuffle(lstWords)
- splitlines(lstWords)
- sleep(3)
- plyWord = raw_input("Identify the word that has been swapped. > ").strip()
- plyword = str.lower(plyWord)
- print
- if plyWord == swappedword:
- print("Congratulations, you answered correctly.")
- else:
- print("You did not guess correctly. The correct answer was "+"'"+swappedword+"'.")
- print
- menu()
- menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement