Create a program in Python that prompts the user to enter an integer number within the range of 1 to 10 inclusive. The program should display “correct input” if the input is within the given range else it should display “wrong input”.

Respuesta :

Python Code with Explanation:

# create a function named func to implement the required logic

def func():

# get the input from the user and store it in a variable named number

   number = int(input("Please enter an integer between 1 to 10 inclusive\n"))

# if the input number is equal or greater than 1 and equal to 10 or less then the input is correct    

   if number>=1 and number<=10:

# print correct input

       return print("Correct input")

# else the input is wrong

   else:

# print wrong input

       return print("Wrong input")

# call the function func

func()

Output:

Test 1:

Please enter an integer between 1 to 10 inclusive

4

Correct input

Test 2:

Please enter an integer between 1 to 10 inclusive

0

Wrong input

Test 3:

Please enter an integer between 1 to 10 inclusive

11

Wrong input

Ver imagen nafeesahmed
Ver imagen nafeesahmed
Ver imagen nafeesahmed

Answer:

dont know if it works!

Explanation:

input=(input("enter number")

if input > 1

print("correct input")

if input <10

print("correct input")

else

print("wrong input")