Answer:
The following are the program in the Python Programming Language
#import package
import random
random.seed(900)
#define a function
def number_guess():
#return random number from 1 to 100
return random.randint(1,100)
#get input in the variable
st = input('Enter numbers: ')
#declare list type variable and split its elements
lst = [int(i) for i in st.split()]
#set the for loop
for i in range(10):
#declare variable that stores the output of the function
n = number_guess()
#check the value of n in the variable lst
if n in lst:
#then, print correct if the number is matched
print(n, 'is correct!')
#print space
print('')
#otherwise,
else:
#set the for loop
for k in lst:
#set the if conditional statement
if abs(k-n)>=15:
#check that k is greater that n
if k>n:
#then, print that if the number is higher
print(k,'is too high')
#otherwise, print that if the number is smaller
else:
print(k,'is too low')
#print the random number
print('Random number was',n)
#print space
print('')
#break the loop
break
Output:
80 is correct!
45 is too high
Random number was 30
48 is correct!
32 is too low
Random number was 97
32 is too high
Random number was 13
32 is too low
Random number was 85
32 is too high
Random number was 11
32 is too low
Random number was 90
32 is correct!
32 is too low
Random number was 93
Step-by-step explanation:
The following are the description of the program.
- Firstly, import the package that is 'random' then, using the seed value 900.
- Then, define a function number_guess() that returns and generate the numbers from 1 to 100.
- Declare variable 'st' that get input from the user and set list type variable 'lst' that splits the following input by the variable 'st'.
- Set the for loop that iterates 10 times then, set the variable 'n' that stores the return values by the function.
- Then, set the for loop that checks the value of the variable 'n' in the variable 'lst' then, print the following number with message.