-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab_session_day1.py
More file actions
36 lines (34 loc) · 942 Bytes
/
lab_session_day1.py
File metadata and controls
36 lines (34 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""write a program to demostarte the following operator in python with example total 8 operators
1.arithematic ,assingment,logical,bit wise,terminate,relational,membership,identity."""
a = int(input("Enter a : "))
b = int(input("Enter b : "))
operator = input('Enter ==,!=,>,<,>=,<=,+, -, *, /,and,or,not : ')
if operator == '+':
print(a + b)
elif operator == '-':
print(a - b)
elif operator == '*':
print(a * b)
elif operator == '/':
if b != 0:
print(a / b)
else:
print("Cannot divide by zero.")
if operator == '==':
print (a == b)
elif operator == '!=':
print (a != b)
elif operator == '>' :
print (a > b)
elif operator == '<':
print (a < b)
elif operator == '>=':
print (a >= b)
elif operator == '<=':
print (a <= b)
if operator == 'and':
print(a < 5 and b < 10)
elif operator == 'or' :
print (a < 5 or b < 4)
elif operator == 'not' :
print (not(a < 5 and b < 10))