0% found this document useful (0 votes)
19 views9 pages

Practical3 2

Vhvc

Uploaded by

shrikantmore3896
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)
19 views9 pages

Practical3 2

Vhvc

Uploaded by

shrikantmore3896
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/ 9

Name : Madhur Bhoskar

Roll no : 56

Batch : CO6I (A)

Practical No. 3: Write a simple Python program using operators:


Arithmetic Operators, Logical Operators, Bitwise Operators

Arithmetic Operators :

print("Arithmatic Operators");

print("8+2=",8+2);

print("8-2=",8-2);

print("8*2=",8*2);

print("8/2=",8/2);

print("8%2=",8%2);

Output:
Logical Operators:

print("Logical Operators");

print("(20 > 10) and (20 < 100):", (20 > 10) and (20 < 100));

print("(15 < 5) and (45 > 5):", (15 < 5) and (45 > 5));

print("(400 > 90) and (5 < 200):", (400 > 90) and (5 < 200));

print("not(10 > 5):", not(10 > 5));

print("not(4 > 5):", not(4 > 5));

Output:
Bitwise Operators :

a = 1;

b = 2;

print("Bitwise Operators");

print("a & b:", a & b);

print("~a:", ~a);

print("~b:", ~b);

print("a ^ b:", a ^ b);

print("a >> b:", a >> b);

print("a << b:", a << b);

print("a | b:", a | b);

Output :
Exercise:
Q.1 Write a program to convert U.S. dollars to Indian rupees.

print("Convert U.S. Dollar to Indian Rupees")

print("1 USD = 85.81 INR")

us = float(input("Enter USD: "))

i_rs = us * 85.81

print("USD =", us, "is equivalent to", i_rs, "Indian Rupees")

Output:

Q.2 Write a program to convert bits to Megabytes, Gigabytes and


Terabytes
print("Convert bit into Byte, KB, MB, GB, TB")
bits = int(input("Enter bit: "))
byte = bits / 8
kb = byte / 1024
mb = kb / 1024
gb = mb / 1024
tb = gb / 1024
print("BYTES =", byte)
print("KILOBYTES =", kb)
print("MEGABYTES =", mb)
print("GIGABYTES =", gb)
print("TERABYTES =", tb)
Output:

Q.3 Write a program to find the square root of a number.

import math
print("Finding Square Root")
num = int(input("Enter the number to find the square root: "))
root = math.sqrt(num)
print("Square root of", num, "is", root)

Output:
Q.4 Write a program to find the area of Rectangle.
l = int(input("Enter the length: "))
b = int(input("Enter the breadth: "))
area = l * b
print("Area of Rectangle:", area)

Output:
Q.5 Write a program to calculate area and perimeter of the square
print("Area & Perimeter of Square")

sq = int(input("Enter the side of square: "))

print("Area of square:", sq * sq)

print("Perimeter of square:", sq * 4)

Output:

Q.6 Write a program to calculate surface volume and area of a cylinder.


pi = 3.14
r = int(input("Enter the radius: "))
h = int(input("Enter the height: "))
v = pi * (r * r) * h
print("Volume of cylinder:", v)
a = 2 * pi * r * h + 2 * pi * (r * r)
print("Surface area of cylinder:", a)
Output :

Q.7 Write a program to swap the value of two variables.


n1 = int(input("Enter the 1st number = "))
n2 = int(input("Enter the 2nd number = "))
temp = n1
n1 = n2
n2 = temp
print("1st number:", n1)
print("2nd number:", n2)

Output:

You might also like