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 again.',

Computer Science & Information Technology

You might also like to view...

The ________ translates the website URL into an IP address because it is easier to remember the URL than a series of numbers

Fill in the blank(s) with correct word

Computer Science & Information Technology

Most Wi-Fi communication uses infrastructure mode.

a. true b. false

Computer Science & Information Technology

What is the output of the following code?enum courses {ALGEBRA, BASIC, PASCAL, PHILOSOPHY, ANALYSIS};courses registered;registered = ALGEBRA;cout << registered << endl;

A. ALGEBRA B. 0 C. 1 D. "ALGEBRA"

Computer Science & Information Technology

Eight bytes grouped together form a bit.

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

Computer Science & Information Technology