0% found this document useful (0 votes)
1 views

Python Assignment -2

The document contains a series of Python programming assignments focused on various conversions and calculations, including weight, distance, area, volume, and unit conversions. Each assignment includes a brief description followed by the corresponding Python code. The tasks range from converting kilograms to grams to calculating the area of geometric shapes and converting between different units of measurement.

Uploaded by

muzahimnawaz
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Python Assignment -2

The document contains a series of Python programming assignments focused on various conversions and calculations, including weight, distance, area, volume, and unit conversions. Each assignment includes a brief description followed by the corresponding Python code. The tasks range from converting kilograms to grams to calculating the area of geometric shapes and converting between different units of measurement.

Uploaded by

muzahimnawaz
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 21

Python Assignment -2

1.Write a program in python to accept weight in KG and convert


it to GRAMS.
Code:
A=int(input("Enter weight in KG="))
B=A*1000
print("The weight in grams is ",B,"")
2. Write a program in python to accept weight in
GRAMS and convert it to KG.
Code:
A=int(input("Enter weight in G="))
B=A/1000
print("The weight in KG is ",B,"")
3. Write a program in python to accept distance
in inch and convert it to feet.
Code:
A=int(input("Enter lenght in inch="))
B=A/12
print("The lenght in feet is ",B,"")
4. Write a program in python to accept distance
in feet and convert it to inch.
Code:
A=int(input("Enter lenght in feet="))
B=A*12
print("The lenght in inch is ",B,"")
5. Write a program to accept base, height and
calculate area of triangle.
Code:
A=int(input("Enter lenght of base="))
B=int(input("Enter lenght of height="))
C=1/2*A*B
print("The area of triangle is ",C,"")
6. Write a program to accept radius and calculate
area of circle.
Code:
A=int(input("Enter lenght of radius="))
C=22/7*A*A
print("The Area of circle is ",C,"")
7. Write a program to calculate of square and
rectangle.
A=int(input("Enter lenght of lenght="))
B=int(input("Enter lenght of breadth="))
C=A*B
print("The Area of rectangle is ",C,"")
8. Write a program in python to calculate
volume of sphere.
Code:
A=int(input("Enter lenght of radius="))
C=4/3*22/7*A*A*A
print("The Area of rectangle is ",C,"")
9. Write a program in python to calculate and
display volume of cone.
Code:
A=int(input("Enter lenght of radius="))
B=int(input("Enter lenght of height="))
C=1/3*22/7*A*A*B
print("The Area of cone is ",C,"")
10. Write a program in python to calculate and
display volume of cylinder.
A=int(input("Enter lenght of radius="))
B=int(input("Enter lenght of height="))
C=22/7*A*A*B
print("The Area of cylinder is ",C,"")
11. Write a program in python to convert
centimeters to meters.
Code:
A=int(input("Enter lenght in cm="))
C=A/100
print("The lenght in m is ",C,"")
12. Write a program in python to convert
meters to centimeters.
Code:
A=int(input("Enter lenght in m="))
C=A*100
print("The lenght in cm is ",C,"")
13. Write a program in python to convert
kilometers to meters.
Code:
A=int(input("Enter volume in liters="))
C=A/3.785
print("The volume in gallons is ",C,"")
14. Write a program in python to convert
meters to kilometers.
Code:
A=int(input("Enter lenght in m="))
C=A/1000
print("The lenght in kilogram is ",C,"")
15. Write a program in python to convert liters to
gallons.
Code:
A=int(input("Enter volume in liters="))
C=A/3.785
print("The volume in gallons is ",C,"")
16. Write a program in python to convert
gallons to liters.
Code:
A=int(input("Enter volume in gallons="))
C=A*3.785
print("The volume in litters is ",C,"")
17. Write a program in python to convert pounds to
kilograms.
Code:
A=int(input("Enter weight in KG="))
C=A/2.205
print("The weight in pounds is ",C,"")
18.Write a program in python to convert
kilograms to pounds.
Code:
A=int(input("Enter weight in pounds="))
C=A*2.205
print("The weight in KG is ",C,"")
19. Write a program to accept a negative
number and convert it into positive.
Code:
A=int(input("Enter negative value="))
C=A+(-A-A)
print("The positive value is is ",C,"")
20. Write a program to convert degree to
radians.
Code:
A=int(input("Enter degree="))
C=A*(22/7)/180
print("radian will be ",C,"")
21. Write a program to convert radians to
degree.
Code:
A=int(input("Enter radian="))
C=A*180/(22/7)
print("degree will be ",C,"")

You might also like