Experiment 3 Programs

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Name: Sangram S Supalkar

Branch: TYCO-B
Roll-84

Experiment 3 Programs

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


us = int(input("Enter US dollars : "))
indian = us * 71.42
print("Indian Rupees : ", indian)
Output
Enter US dollars : 3
Indian Rupees : 214.26
Name: Sangram S Supalkar
Branch: TYCO-B
Roll-84

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


bits = int(input("Enter bits : "))
bytes = bits / 8
KB = bytes / 1024
MB = KB / 1024
GB = MB / 1024
TB = GB / 1024
print("Bytes : {:.2F}".format(bytes), "bytes")
print("KiloBytes (KB) : {:.2F}".format(KB), "KB")
print("Megabytes (MB) : {:.2F}".format(MB), "MB")
print("GigaBytes (GB) : {:.2F}".format(GB), "GB")
print("TeraBytes (TB) : {:.2F}".format(TB), "TB")
Output
Enter bits : 99999999999
Bytes : 12499999999.88 bytes
KiloBytes (KB) : 12207031.25 KB
Megabytes (MB) : 11920.93 MB
GigaBytes (GB) : 11.64 GB
TeraBytes (TB) : 0.01 TB
Name: Sangram S Supalkar
Branch: TYCO-B
Roll-84

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


import math
num = int(input("Enter a number : "))
sqroot = math.sqrt(num)
print("Square root of ", num, " is ", sqroot)
Output
Enter a number : 4
Square root of 4 is 2.0
Name: Sangram S Supalkar
Branch: TYCO-B
Roll-84

Q.4 Write a program to find the area of Rectangle


l = int(input("Enter Length of rect : "))
b = int(input("Enter width of rect : "))
area = l * b
print("Area of rectangle : ", area)
Output
Enter Length of rect : 4
Enter width of rect : 5
Area of rectangle : 20
Name: Sangram S Supalkar
Branch: TYCO-B
Roll-84

Q.5 Write a program to calculate area and perimeter of square.


side = int(input("Enter side of a square : "))
area = side * side
peri = 4 * side
print("Area of square : ", area)
print("Perimeter of square : ", peri)
Ouput
Enter side of a square : 4
Area of square : 16
Perimeter of square : 16
Name: Sangram S Supalkar
Branch: TYCO-B
Roll-84

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


import math
r = int(input("Enter Radius : "))
h = int(input("Enter Height : "))
Sarea = ((2 * math.pi) * (r * r)) + (2 * math.pi) * r * h
Svolume = math.pi * (r * r) * h
print("Surface Volume of cylinder : {:.2F}".format(Svolume))
print("Surface Area of cylinder {:.2F}".format(Sarea))
Output
Enter Radius : 3
Enter Height : 5
Surface Volume of cylinder : 141.37
Surface Area of cylinder 150.80
Name: Sangram S Supalkar
Branch: TYCO-B
Roll-84

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


var1 = 30
var2 = 20
print("Before Swap")
print("var1 = ", var1, " var2 = ", var2)
temp = var1
var1 = var2
var2 = var1
print("After Swap")
print("var1 = ", var1, " var2 = ", var2)
Output
Before Swap
var1 = 30 var2 = 20
After Swap
var1 = 20 var2 = 20

You might also like