You are on page 1of 3

Exp-1

Name:- Aayush Kumar

Roll no.:- 12112126

Section:- CSB-06

Q1)
import math

def cylinder_area_and_volume(radius, length):


# calculate the area
area = 2 * math.pi * radius * (radius + length)
# calculate the volume
volume = math.pi * radius ** 2 * length
print("Area of cylinder is " + str(area))
print("volume of cylinder is " + str(volume))

radius = int(input("Enter the radius:- "))


length = int(input("Enter the length:- "))

cylinder_area_and_volume(radius,length)

Output:-

Q2)
celsius = float(input("Enter temperature in Celsius: "))

fahrenheit = (celsius * 9/5) + 32

print("%.2f Celsius is equal to %.2f Fahrenheit" %(celsius, fahrenheit))

Output:-

Q3)
feet = float(input("Enter distance in feet: "))

meter_per_foot = 0.3048

meters = feet * meter_per_foot

print("%.2f feet is equal to %.4f meters" %(feet, meters))

Output:-

Q4)

weight_in_pounds = float(input("Enter weight in pounds: "))


weight_in_kilograms = weight_in_pounds * 0.454
print("Weight in kilograms:", weight_in_kilograms)

Output:-

Q5)

def is_prime(n):
if n <= 1:
return False
for i in range(2, n):
if n % i == 0:
return False
return True

def sum_of_primes(n):
prime_sum = 0
for i in range(2, n):
if is_prime(i):
prime_sum += i
return prime_sum

n = int(input("Enter a number: "))


print("Sum of all prime numbers less than", n, "is", sum_of_primes(n))

Output:-
Q6)
import math

x1 = float(input("Enter x-coordinate of first point: "))


y1 = float(input("Enter y-coordinate of first point: "))
x2 = float(input("Enter x-coordinate of second point: "))
y2 = float(input("Enter y-coordinate of second point: "))

distance = math.sqrt((x2 - x1)**2 + (y2 - y1)**2)

print("Distance between the points:", distance)

Output:-

Q7)
mass = float(input("Enter the amount of water in kilograms: "))
temp_initial = float(input("Enter the initial temperature of the water in Celsius: "))
temp_final = float(input("Enter the final temperature of the water in Celsius: "))

energy = mass * 4184 * (temp_final - temp_initial)

print("The energy needed to heat the water is", energy, "joules.")

Output:-

You might also like