0% found this document useful (0 votes)
4 views8 pages

3,4,5

The document contains practical exercises demonstrating the use of arithmetic, logical, and bitwise operators in Python, along with control flow statements like if-else and loops. Each section includes code snippets and expected outputs for various operations. The exercises are attributed to a student named Mane Priti Shrinivas with a roll number of 24/36-28.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views8 pages

3,4,5

The document contains practical exercises demonstrating the use of arithmetic, logical, and bitwise operators in Python, along with control flow statements like if-else and loops. Each section includes code snippets and expected outputs for various operations. The exercises are attributed to a student named Mane Priti Shrinivas with a roll number of 24/36-28.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Practical No.

Name: Mane Priti Shrinivas Roll No:24/36-28


Arithmetic Operators

num1 = 10 num2 = 3 #

Addition addition = num1

+ num2 print("Addition:",

addition)

# Subtraction subtraction =
num1 - num2

print("Subtraction:", subtraction)

# Multiplication multiplication =

num1 * num2 print("Multiplication:",

multiplication)

# Division division =
num1 / num2

print("Division:", division)

# Floor Division floor_division =

num1 // num2 print("Floor Division:",

floor_division)

# Modulus modulus = num1


% num2 print("Modulus:",
modulus) # Exponentiation
exponentiation = num1 **
num2
print("Exponentiation:",

exponentiation)

Output:

Logical Operators
# Define two boolean variables

a = True b = False

# Logical AND and_result = a and

b print("Logical AND:",

and_result)

# Logical OR or_result = a or

print("Logical OR:", or_result)

# Logical NOT not_result_a = not a not_result_b

= not b
print("Logical NOT of a:", not_result_a)

print("Logical NOT of b:", not_result_b) Output:

Bitwise Operators

# Define two numbers

a = 10 b = 4

# Bitwise AND and_result = a &

b print("Bitwise AND:",

and_result)

# Bitwise OR or_result

=a|b

print("Bitwise OR:", or_result)

# Bitwise XOR xor_result = a ^ b

print("Bitwise XOR:", xor_result)

# Bitwise NOT not_result_a

= ~a not_result_b = ~b
print("Bitwise NOT of a:", not_result_a)

print("Bitwise NOT of b:", not_result_b) # Bitwise


left shift left_shift_a = a << 1 left_shift_b = b << 1

print("Bitwise left shift of a by 1:", left_shift_a)

print("Bitwise left shift of b by 1:", left_shift_b)

# Bitwise right shift right_shift_a = a >> 1

right_shift_b = b >> 1 print("Bitwise right shift of

a by 1:", right_shift_a) print("Bitwise right shift of

b by 1:", right_shift_b)

Output:
Practical No.4
Name: Mane Priti Shrinivas Roll No:24/36-28
if Statement
if 10 > 5: print("10
greater than 5")

print("Program ended")

Output:

If…..else Statement

x = 3 if x ==
4:
print("Yes")
else:

print("No")

Output:

Nested if Statement
num = 15 if num > 10:
print("Number is greater than 10.")

if num % 2 == 0:

print("Number is even.")

else: print("Number is

odd.") Output:
Practical No.5

Name: Mane Priti Shrinivas Roll No:24/36-28


While Loop
i = 1 while i

<= 5:

print(i)

i += 1

Output:

For Loop

text = "Hello" for

char in text:

print(char) Output:

Nested Loops

n = 5 for i in range(n):

for j in range(n - i - 1):


print(" ", end="") for k

in range(2 * i + 1):

print("*", end="") print()

Output:

You might also like