Computer Science, asked by vivekchaudhari1572, 9 months ago

Write a program in Python to explain logical operators.

Answers

Answered by ridhimakh1219
4

Write a program in Python to explain logical operators.

Explanation:

Python program to use logical operators

x = int(input('Enter your age: '))

if x > 0 and x < 21:

   print('You are still a child!')

elif x > 21 and x < 40:

   print('You are so young!')

elif x > 40 and x < 60:

   print('You are not that young, but not that old also!')

elif x > 60 and x < 100:

   print ('Golden ages!')

elif x < 0 or x > 100:

   print ('I do not really believe you that you are younger than 0 or older than 100!')

else:

   print ('Invalid selection.')

OUTPUT-1

Enter your age: 58

You are not that young, but not that old also!

OUTPUT-2

Enter your age: 12

You are still a child!

OUTPUT-3

Enter your age: 105

I do not really believe you that you are younger than 0 or older than 100!

OUTPUT-4

Enter your age: -6

I do not really believe you that you are younger than 0 or older than 100!

OUTPUT-5

Enter your age: 25

You are so young!

OUTPUT-6

Enter your age: 68

Golden ages!

Similar questions