SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 5 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 17 Dec 2017 My Price 7.00

guess = input("Guess a random number between 1 and 10. ")

Python

 

What would I have to add to this code to have it generate 2 numbers instead of one, and also to give the sum of the numbers as a hint for users?

 

 

 

 

 

 

 

random_number = random.randint(1,10)

tries = 0

tries_remaining = 5

 

 

 

 

 

 

while tries < 5:

guess = input("Guess a random number between 1 and 10. ")

tries += 1

tries_remaining -= 1

 

 

 

try:

guess_num = int(guess)

except:

print("That's not a whole number!")

break

 

 

 

if not guess_num > 0 or not guess_num < 11:

print("That number is not between 1 and 10.")

break

 

 

 

elif guess_num == random_number:

print("Congratulations! You are correct!")

print("It took you {} tries.".format(tries))

break

 

 

elif guess_num < random_number:

if tries_remaining > 0:

print("I'm sorry, that number is low. You have {} tries remaining.".format(int(tries_remaining)))

continue

else:

print("Sorry, but my number was {}".format(random_number))

print("You are out of tries. Better luck next time.")

 

 

 

 

elif guess_num > random_number:

if tries_remaining > 0:

print("I'm sorry, that number is high. You have {} tries remaining.".format(int(tries_remaining)))

continue

else:

print("Sorry, but my number was {}".format(random_number))

print("You are out of tries. Better luck next time.")

Answers

(5)
Status NEW Posted 17 Dec 2017 12:12 PM My Price 7.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)