def displayInstructions(): instructionList = ['Welcome to the Remember game.', 'I will show you a series of words.', 'After showing these words,', 'I will ask you which one started with a ', 'particular letter and you should tell me.', 'You win if you pick the right word.', 'Otherwise you lose the game.'] for instruction in instructionList: uagui.drawString(instruction) uagui.inputString('Press the enter key to continue') resetDisplay()
def displayWords() : # Display the words wordList = ['orange', 'chair', 'mouse', 'sandwich'] index = random.randint(0, len(wordList) - 1) for word in wordList: uagui.drawString(word) time.sleep(2.5) resetDisplay() return wordList[index]
# This program plays the Remember game where the game # displays a sequence of words and the user tries to # remember which word began with a particular letter. import time, uagui # Main Program.openWindow('Remember the Word', 900, 700) uagui.setFontSize(50) uagui.drawString('Welcome to the Remember game.') uagui.drawString('I will show you a series of words.') uagui.drawString('After showing these words,') uagui.drawString('I will ask you which one started with a ') uagui.drawString('particular letter and you should tell me.') uagui.drawString('You win if you pick the right word.') uagui.drawString('Otherwise you lose the game.') uagui.inputString('Press the enter key to continue') uagui.clearWindow() uagui.movePen() # Display the words uagui.drawString('orange') time.sleep(2.5) uagui.clearWindow() uagui.movePen() uagui.drawString('chair') time.sleep(2.5) uagui.clearWindow() uagui.movePen() uagui.drawString('mouse') time.sleep(2.5)
#import time and uagui module import time,uagui #Open the window uagui.openWindow('Remember The Word',500,400) # Create instruction list instructions=['Welcome to the Remember game.', 'I will show you a series of words.', 'After showing these words,', 'I will ask you which one started with a ','particular letter and you should tell me.', 'You win if you pick the right word.', 'Otherwise you lose the game.' ] #Use Repetition Control Structure to display instructions #New statement type - for for line in instructions: uagui.drawString(line) #Prompt the player to press the enter key uagui.inputString('Press the enter key to continue') #Erase instruction and move cursor to top left corner uagui.clearWindow() uagui.movePen() #Create word list wordList=['orange','chair','mouse','sandwich'] #Display word, pause for 2 sec, clear word and move cursor for aWord in wordList: uagui.drawString(aWord) time.sleep(2) uagui.clearWindow() uagui.movePen() #Prompt the user with the question
# Display the words wordList = ['orange', 'chair', 'mouse', 'sandwich'] index = random.randint(0, len(wordList) - 1) for word in wordList: uagui.drawString(word) time.sleep(2.5) resetDisplay() return wordList[index] def getPlayerAnswer() : playerAnswer = uagui.inputString('What word began with the letter c?') uagui.clearWindow() uagui.movePen() return playerAnswer if playerAnswer == 'chair' : uagui.drawString('Congratulatons, you are correct.') else : uagui.drawString('Sorry, you selected ' + playerAnswer) uagui.drawString('The correct answer was ' + 'chair') uagui.inputString('Press enter to close the window.') uagui.closeWindow() uagui.clearWindow() uagui.movePen() main()