Got Homework?
Connect with other students for help. It's a free community.
Here's the question you clicked on:
 0 viewing
x123x123
Group Title
I need help with a python programming problem. the question is, modify the guess my number chapter project by reusing the function ask_number(). here is the guess my number programimport random
print("welcome")
print("number between 1100")
print("guess")
the_number = random.randint(1, 100)
guess = int(input("take a g:"))
tries = 1
lose = 10
while guess != the_number and tries < lose:
if guess > the_number:
print("lower")
else:
print("higher")
guess =int(input("take a guess"))
tries += 1
if tries == lose:
print("You have exceeded your max number of attempts; therefore, you lose!")
else:
print("you guessed it! the number was", the_number)
print("and it only took you", tries, "tries!\n")
input("\n\nPress the enter key the exit.") here is the the ask_number function
def ask_number(question, low, high ):
"""Ask for a number within a range."""
response = None
while response not in range(low, high ):
response = int(input(question))
return response
 one year ago
 one year ago
x123x123 Group Title
I need help with a python programming problem. the question is, modify the guess my number chapter project by reusing the function ask_number(). here is the guess my number programimport random print("welcome") print("number between 1100") print("guess") the_number = random.randint(1, 100) guess = int(input("take a g:")) tries = 1 lose = 10 while guess != the_number and tries < lose: if guess > the_number: print("lower") else: print("higher") guess =int(input("take a guess")) tries += 1 if tries == lose: print("You have exceeded your max number of attempts; therefore, you lose!") else: print("you guessed it! the number was", the_number) print("and it only took you", tries, "tries!\n") input("\n\nPress the enter key the exit.") here is the the ask_number function def ask_number(question, low, high ): """Ask for a number within a range.""" response = None while response not in range(low, high ): response = int(input(question)) return response
 one year ago
 one year ago

This Question is Open

snark Group TitleBest ResponseYou've already chosen the best response.0
it seems ok... you need to include: import random # the random number module at the top, and it seems to work.
 one year ago

x123x123 Group TitleBest ResponseYou've already chosen the best response.0
Thanks for taking a look at the code for me…Yeah; I got the top of the code to work fine. The problem was incorporating the ask_number function into the program. The challenge is to take a project I did out of chapter 3 which was guess my number and modify it by reusing the ask_number function.
 one year ago
See more questions >>>
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.