Practical No 2.python
Practical No 2.python
Class:-Co4k(B)
Roll no:-64
Subject:-python(314004)
Practical no:-03
*Arithmetic operator in python
Code:-
a = 10
b=5
sum_result = a + b
diff_result = a - b
mul_result = a * b
div_result = a / b
mod_result = a % b
exp_result = a ** b
Output:-
Sum: 15
Difference: 5
product: 50
Division: 2.0
Modulus: 0
Exponentiation: 100000
*Logical operator
Code:-
x = True
y = False
logical_and = x and y
logical_or = x or y
logical_not = not x
Output:-
Logical AND: False
Logical OR: True
Logical NOT: False
*Bitwise operator
Code:-
num1 = 5
num2 = 3
bitwise_and = num1 & num2
bitwise_or = num1 | num2
bitwise_xor = num1 ^ num2
bitwise_not = ~num1
bitwise_left_shift = num1 << 1
bitwise_right_shift = num1 >> 1
Output:-
Bitwise AND: 1
Bitwise OR: 7
Bitwise XOR: 6
Bitwise NOT: -6
Bitwise Left Shift: 10
Bitwise Right Shift: 2