well, i am to improve ask_number to call the function with a step value, and then i am supposed to use the function ask_number() in this:
-
# Guess My Number
-
#
-
# The computer picks a random number between 1 and 100
-
# The player tries to guess it and the computer lets
-
# the player know if the guess is too high, too low
-
# or right on the money
-
-
import random
-
-
print "\tWelcome to 'Guess My Number'!"
-
print "\nI'm thinking of a number between 1 and 100."
-
print "Try to guess it in as few attempts as possible.\n"
-
-
# set the initial values
-
the_number = random.randrange(100) + 1
-
guess = int(raw_input("Take a guess: "))
-
tries = 1
-
-
#guessing loop
-
while (guess != the_number):
-
if (guess > the_number):
-
print "Lower..."
-
tries += 1
-
else:
-
print "Higher..."
-
tries += 1
-
-
guess = int(raw_input("Take a guess: "))
-
-
print "You guessed it! The number was", the_number
-
print "And it only took you", tries, "tries!\n"
-
-
raw_input("\n\nPress the enter key to exit.")
-
Then I am supposed to modify that to put the main code into a function called main()
But back to my original question. I don't see what changing it will do to benefit me. I understand that i could use it in it's current form, but adding a step value? What? I am not exactly sure how clear I am being with what I am required to do, so I will lay it out once more.
1. Improve the function ask_number() so that the function can be called with a step value. Make the default value of step
1. --ask_number() is provided by the book I am using and is in my first post.
2. Modify the Guess My Number chapter project from Chapter 3 by reusing the function ask_number() --The code for Guess My Number is up above and is also provided by the book I am using.
3. Modify the new version of Guess My Number you created in the the last challenge(number 2) so that the program's code is in a function called main(). Don't forget to call main() so that you can play the game.
I think I understand how to make it a step function, but i'm not sure how to do it to implement it into the Guess My Number program in a useful way.
Any help is appreciated! Thank you!