0% found this document useful (0 votes)
3 views2 pages

Python Programs Solutions Part1

The document contains a series of Python code snippets for basic mathematical operations, including addition, subtraction, multiplication, division, and modulo. It also includes temperature conversions between Celsius and Fahrenheit, as well as calculations for the area and perimeter of a rectangle, area and circumference of a circle, and the volume of a cylinder and cone. Each snippet prompts the user for input and prints the corresponding result.

Uploaded by

vaibhavebox9
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)
3 views2 pages

Python Programs Solutions Part1

The document contains a series of Python code snippets for basic mathematical operations, including addition, subtraction, multiplication, division, and modulo. It also includes temperature conversions between Celsius and Fahrenheit, as well as calculations for the area and perimeter of a rectangle, area and circumference of a circle, and the volume of a cylinder and cone. Each snippet prompts the user for input and prints the corresponding result.

Uploaded by

vaibhavebox9
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

1) Sum of two numbers

a = int(input('Enter first number: '))


b = int(input('Enter second number: '))
print('Sum:', a + b)

2) Difference of two numbers

a = int(input('Enter first number: '))


b = int(input('Enter second number: '))
print('Difference:', a - b)

3) Product of two numbers

a = int(input('Enter first number: '))


b = int(input('Enter second number: '))
print('Product:', a * b)

4) Division of two numbers

a = int(input('Enter first number: '))


b = int(input('Enter second number: '))
if b != 0:
print('Division:', a / b)
else:
print('Cannot divide by zero')

5) Modulo division

a = int(input('Enter first number: '))


b = int(input('Enter second number: '))
if b != 0:
print('Modulo:', a % b)
else:
print('Cannot modulo by zero')

6) Centigrade to Fahrenheit

c = float(input('Enter temperature in Celsius: '))


f = (c * 9/5) + 32
print('Temperature in Fahrenheit:', f)

7) Fahrenheit to Centigrade

f = float(input('Enter temperature in Fahrenheit: '))


c = (f - 32) * 5/9
print('Temperature in Celsius:', c)

8) Area and perimeter of rectangle


l = float(input('Enter length: '))
b = float(input('Enter breadth: '))
area = l * b
perimeter = 2 * (l + b)
print('Area:', area)
print('Perimeter:', perimeter)

9) Area and circumference of a circle

r = float(input('Enter radius: '))


area = 3.1416 * r * r
circumference = 2 * 3.1416 * r
print('Area:', area)
print('Circumference:', circumference)

10) Volume of cylinder and cone

r = float(input('Enter radius: '))


h = float(input('Enter height: '))
volume_cylinder = 3.1416 * r**2 * h
volume_cone = (1/3) * 3.1416 * r**2 * h
print('Cylinder Volume:', volume_cylinder)
print('Cone Volume:', volume_cone)

You might also like