assign3_ptI.py

# assign3_ptI.py - #Assignment 2#Random Number Game#Name...

• Homework Help
• 1

This preview shows page 1. Sign up to view the full content.

#Assignment 2 #Random Number Game #Name: Brittany Wojciehowski import random #random number module numAttempts = 0 #Number of attempts print("Hey There! What's your name?") userName = input() number = random.randint(1, 20) print("Hello", userName, ", I am thinking of a number between 1 and 20.") while numAttempts < 3: #Establishing number of attempts allowed print("Give me a guess!") guess = input() guess = int(guess) numAttempts = numAttempts + 1 if guess < number: #If guess is too low print("Your guess is too low.") if guess > number:
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: #If guess is too hight print("Your guess is too high.") if guess == number: # What to do if user guesses correctly break if guess == number: #Where the program jumps to after the user guesses correctly numAttempts = str(numAttempts) print("Great job, ", userName, "! You guessed my number in ", numAttempts, " guesses!") if guess != number: #Where program jumps to if user has used all guesses and didn't guess correcly number = str(number) print("Too Bad. The number I was thinking of was ", number, ".")...
View Full Document

• Fall '15

{[ 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