-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprac3.py
More file actions
47 lines (38 loc) · 1.02 KB
/
Copy pathprac3.py
File metadata and controls
47 lines (38 loc) · 1.02 KB
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
37
38
39
40
41
42
43
44
45
46
#practical 3
print (" ******** Madanraj SAGAR *******")
# Arithmetic oprator
x = 5
y = 3
print(x + y)
print(x - y)
print(x * y)
print(x / y)
print(x % y)
print(x ** y) #same as 2*2*2*2*2
print(x // y)
#the floor division // rounds the result down to the nearest whole number
#Python Bitwise Operators
a = 10
b = 4
# Print bitwise AND operation
print("a & b =", a & b)
# Print bitwise OR operation
print("a | b =", a | b)
# print bitwise XOR operation
print("a ^ b =", a ^ b)
# Print bitwise NOT operation
print("~a =", ~a)
# print bitwise right shift operator
print("a >> 1 =", a >> 1)
print("b >> 1 =", b >> 1)
# print bitwise left shift operator
print("a << 1 =", a << 1)
print("b << 1 =", b << 1)
#Python logical Operators
x = 5
print(x > 3 and x < 10)
# returns True because 5 is greater than 3 AND 5 is less than 10
print(x > 3 or x < 4)
# returns True because one of the conditions are true (5 is greater than 3, but 5 is not less than 4)
print(not(x > 3 and x < 10))
# returns False because not is used to reverse the result