Programming With Python Practical 3

Question 1
Write a program to convert U.S. dollars to Indian rupees.
currency.py
C
				num=int(input("Enter a currency in US Dollars: "))
d=83.61
inr=num*d;
print("Amount in indian rupees is: ",inr)
			
Output
Question 2
Write a program to convert bits to Megabytes, Gigabytes and Terabytes
bits.py
Pyton
				bits=int(input("Enter total number of bits: "))
by=bits/8;
kb=by/1000
mb=kb/1000
gb=mb/1000
tb=gb/1000
print("Megabytes are: ",mb)
print("Gigabytes are: ",gb)
print("Terabytes are: ",tb)

			
Output
Question 3
Write a program to find the square root of a number
root.py
Pyton
				num=int(input("Enter a number: "))
root=num**(1/2)
print("Square root is: ",root)

			
Output
Question 4
Write a program to find the area of Rectangle
rectangle.py
Pyton
				l=int(input("Enter length of rectangle: "))
b=int(input("Enter width of rectangle: "))
area=l*b
print("Area of rectangle is: ",area)

			
Output
Question 5
Write a program to calculate area and perimeter of the square
square.py
Pyton
				s=int(input("Enter side of a square: "))
area=s**2
peri=s*4
print("Area of square is: ",area)
print("Perimeter of square is: ",peri)

			
Output
Question 6
Write a program to calculate surface volume and area of a cylinder.
cylinder.py
Pyton
				r=int(input("Enter radius of a cylinder: "))
h=int(input("Enter height of a cylinder: "))
vol=3.14*r*r*h
area=2*3.14*r*h+2*3.14*r*r
print("Volume of cylinder is: ",vol)
print("Area of cylinder is: ",area)
			
Output
Question 7
Write a program to swap the value of two variables.
swap.py
Pyton
				a=int(input("Enter first number: "))
b=int(input("Enter second number: "))
temp=a
a=b
b=temp
print("After swapping")
print("First number is: ",a)
print("Second number is: ",b)

			
Output

Leave a Comment

Your email address will not be published. Required fields are marked *