hw3 - # # homework3.py # This module contains the solutions...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
################################ # homework3.py # This module contains the solutions to Homework 3. # Sam Orr, <sam.orr@fandm.edu>, 10/12/2010 ###################### # import random i def guessNumber (): ''' This function initiates a guessing game, in which, the player tries to guess a randomly generated number in 3 tries. The function generates a random number between 1 and 9. If the guess is smaller than the generated number, the function will print, "too small".If the guess is larger than the generated number, the function will print, "too big". If the number is correctly guessed, the function will print, "you win". If after three tries the number is not guessed, the function will print, "you lose". The function has no parameters, but calls for a user input, which are the guesses made by the player. ''' number = random.randint (1,9) for tries in range (3): guess = input ("guess: ") if int(guess) > number: print ("too big: ") elif int(guess) < number: print ("too small: ") else: return "you win" if int(guess) != number: guess3 = input ("you lose") def caesarEncrypt (message, numShift): ''' This function takes a message and encrypts it in what is knonw as
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

hw3 - # # homework3.py # This module contains the solutions...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online