Monday 7 February 2022

Python practice programs for beginners - Day8

 

Python practice programs for beginners - millioninformations


Day 7 Solutions:



a=int(input("Enter the number: "))
b=int(input("Enter the number: "))
print(f'{a} is greater than ">" {b} True or False? Result:{a>b}')
print(f'{a} is Lesser than "<" {b} True or False? Result:{a<b}')
print(f'{a} is equals to "==" {b} True or False? Result:{a==b}')
print(f'{a} is not equals to "!=" {b} True or False? Result:{a!=b}')
print(f'{a} is greater than or equals to ">=" {b} True or False? Result:{a>=b}')
print(f'{a} is lesser than or equals to "<=" {b} True or False? Result:{a<=b}')


Output:

Enter the number: 4
Enter the number: 4
4 is greater than ">" 4 True or False? Result: False
4 is Lesser than "<" 4 True or False? Result: False
4 is equal to "==" 4 True or False? Result: True
4 is not equal to "!=" 4 True or False? Result: False
4 is greater than or equals to ">=" 4 True or False? Result: True
4 is lesser than or equals to "<=" 4 True or False? Result: True


Day 8: Logical Operator

Logical Operators helps us to check more than one condition at a time.

we have 3 operators.

and - returns True when both operands return true else false

or - returns True if at least one of the operands is true.

not - returns True if the specified condition is not met.

and Operator:


Example:

a=10

b=10

c=10


a==b and a==c --> True

(True) and (True) --> True

a=11

b=10

c=10

a==b and a==c --> False

(False) and (True) --> False


or Operator:

a=11

b=10

c=10

a==b and a==c --> False

(False) and (True) --> True


not Operator:

not(b==c)

not(True) --> False


Task: Try to use these operators and check various conditions.








1 comment :