{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

################################ # homework3.py # This module contains the solutions to Homework 3. # Sam Orr, <[email protected]>, 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 Caesar Cipher. It is a substitution cipher, in which each letter in

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern