In: Computer Science
Write if logic in Python that checks if a variable named number is either greater than, less than , or equal to 10 and prints out the number with the appropriate message, for example, if number is 6 you would output: number,"less than 10" or 6 less than 10
Python code:
#accepting number from user
number=int(input())
#checking if number is greater than 10
if(number>10):
#printing greater than 10
print(str(number)+" greater than 10")
#checking if number is less than 10
elif(number<10):
#printing less than 10
print(str(number)+" less than 10")
else:
#printing equal to 10
print(str(number)+" equal to 10")
Screenshot:
Input and Output: