Rewrite exercise 15 to call the function with a random number between 0 and 10 inclusive. (Hint: The randint function in the random library returns a random number between its two arguments inclusive.)

What will be an ideal response?


$ cat number_guess2.py #!/usr/bin/python from random import randint
def guessANumber(val):
guess = int(input('Enter your guess: ')) if guess > val:
print 'Too high.' return 1 elif guess < val:
print 'Too low.' return -1 else:
print 'Got it!' return 0
val = randint(0,10) while (guessANumber(val) != 0):
print 'Guess ag

Computer Science & Information Technology

You might also like to view...

All of the following methods are implicitly final except:

a. a method in an abstract class. b. a private method. c. a method declared in a final class. d. static method.

Computer Science & Information Technology

A degree of separation in a graph is a sequence of edges that leads from one node to another.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

If you upsample, Photoshop assigns a new color to the pixel based on an average ____.

a. indexing b. concatenation c. interpolation d. losing

Computer Science & Information Technology

Describe the purpose of exit plans.

What will be an ideal response?

Computer Science & Information Technology