Sunday, September 28, 2025

Python Program Collection 05 - Convert temperature in Fahrenheit , celcisus, convert IC to NC, Dollar to NC, km to M

 Python Program Collection 05 - Convert temperature in Fahrenheit , celcisus, convert IC to NC, Dollar to NC, km to M



56. To accept temperature in Fahrenheit  from user and convert into the Celsius.

fahrenheit = float(input("Enter Temperature in Fahrenheit: "))

celsius = (fahrenheit - 32) * 5 / 9

print("Temperature in Celsius:", celsius)

 

 

57. To accept temperature in Celsius from user and convert into the Fahrenheit.

fah = float(input("Enter Temperature in Fahrenheit: "))

cel = (fah - 32) * 5 / 9

print("Temperature in Celsius:", cel)

 

58. To accept currency value in nepalese rupees and convert into indian currency

npr = float(input("Enter amount in Nepalese Rupees (NPR): "))

inr = npr / 1.6

print("Equivalent amount in Indian Rupees (INR):", inr)

 

59. To accept currency value in indian currency and convert into nepalese rupees

inr = float(input("Enter amount in Indian Rupees (INR): "))

npr = inr * 1.6

print("Equivalent amount in Nepalese Rupees (NPR):", npr)

 

60. To accept currency value in dollar and convert into nepalese rupees

usd = float(input("Enter amount in US Dollars (USD): "))

npr = usd * 133

print("Equivalent amount in Nepalese Rupees (NPR):", npr)

 

61. To accept currency value in nepalese rupees and convert into dollar.

npr = float(input("Enter amount in Nepalese Rupees (NPR): "))

usd = npr / 133

print("Equivalent amount in US Dollars (USD):", usd)

62. Input days and convert into years, months and days.

days = int(input("Enter number of days: "))

years = days // 365

remaining_days = days % 365

months = remaining_days // 30

days_left = remaining_days % 30

print("Years:", years)

print("Months:", months)

print("Days:", days_left)

 

 

63. Input seconds and convert into hours minutes and seconds.

seconds = int(input("Enter time in seconds: "))

hours = seconds // 3600

remaining_seconds = seconds % 3600

minutes = remaining_seconds // 60

seconds_left = remaining_seconds % 60

print("Hours:", hours)

print("Minutes:", minutes)

print("Seconds:", seconds_left)

 

64. Input distance in kilometer and convert into meter.

km = float(input("Enter distance in kilometers: "))

m = km * 1000

print("Distance in meters:", m)

 

65. Input distance in meter and convert into kilometer and meter.

m = float(input("Enter distance in meters: "))

km = m / 1000

print("Distance in kilometers:", km)


Python Program Collection 04 - Calculate Simple Interest, Profit, Loss, Profit/Loss Percentage

 Python Program Collection 04 - Calculate Simple Interest, Profit, Loss, Profit/Loss Percentage




43. Display simple interest

principal = float(input("Enter the Principal amount: "))

time = float(input("Enter the Time (in years): "))

rate = float(input("Enter the Rate of Interest (% per annum): "))

simple_interest = (principal * time * rate) / 100

print("The Simple Interest is:", simple_interest)

 

44. Input principal, rate, time and display total amount.

principal = float(input("Enter the Principal amount: "))

time = float(input("Enter the Time (in years): "))

rate = float(input("Enter the Rate of Interest (% per annum): "))

simple_interest = (principal * time * rate) / 100

total_amount = principal + simple_interest

print("The Total Amount (Principal + Interest) is:", total_amount)

 

45. Input principal, rate, time and display simple interest and total amount.

principal = float(input("Enter the Principal amount: "))

time = float(input("Enter the Time (in years): "))

rate = float(input("Enter the Rate of Interest (% per annum): "))

 

simple_interest = (principal * time * rate) / 100

total_amount = principal + simple_interest

print("The Simple Interest is:", simple_interest)

print("The Total Amount (Principal + Interest) is:", total_amount)

 

46. Input amount, rate, time and display principal.

amount = float(input("Enter the Total Amount: "))

rate = float(input("Enter the Rate of Interest (% per annum): "))

time = float(input("Enter the Time (in years): "))

principal = amount / (1 + (rate * time) / 100)

print("The Principal is:", principal)

 

47. Input simple interest, rate, time and display principal.

simple_interest = float(input("Enter the Simple Interest: "))

rate = float(input("Enter the Rate of Interest (% per annum): "))

time = float(input("Enter the Time (in years): "))

principal = (simple_interest * 100) / (rate * time)

print("The Principal is:", principal)


48. Calculate profit

cp = float(input("Enter the Cost Price (CP): "))

sp = float(input("Enter the Selling Price (SP): "))

profit = sp - cp

print("The Profit is:", profit)

 

 

49. Calculate loss

cp = float(input("Enter the Cost Price (CP): "))

sp = float(input("Enter the Selling Price (SP): "))

loss = cp - sp

print("The Loss is:", loss)

 

50E. Python Program (Profit or Loss Calculator)

cp = float(input("Enter the Cost Price (CP): "))

sp = float(input("Enter the Selling Price (SP): "))

 

if sp > cp:

    profit = sp - cp

    print("Profit =", profit)

elif cp > sp:

    loss = cp - sp

    print("Loss =", loss)

else:

    print("No Profit, No Loss")

 

50. Calculate profit percentage

cp = float(input("Enter the Cost Price (CP): "))

sp = float(input("Enter the Selling Price (SP): "))

profit = sp - cp

profit_percent = (profit / cp) * 100

print("Profit =", profit)

print("Profit Percentage =", profit_percent, "%")

 

51. Calculate loss percentage

cp = float(input("Enter the Cost Price (CP): "))

sp = float(input("Enter the Selling Price (SP): "))

loss = cp - sp

loss_percent = (loss / cp) * 100

print("Loss =", loss)

print("Loss Percentage =", loss_percent, "%")

 

51E. Python Program (Profit or Loss Percentage)

cp = float(input("Enter the Cost Price (CP): "))

sp = float(input("Enter the Selling Price (SP): "))

if sp > cp:

    profit = sp - cp

    profit_percent = (profit / cp) * 100

    print("Profit =", profit)

    print("Profit Percentage =", profit_percent, "%")

elif cp > sp:

    loss = cp - sp

    loss_percent = (loss / cp) * 100

    print("Loss =", loss)

    print("Loss Percentage =", loss_percent, "%")

else:

    print("No Profit, No Loss")

 

52. Calculate selling price  where profit percentage and cost price is given

cp = float(input("Enter the Cost Price (CP): "))

profit_percent = float(input("Enter the Profit Percentage: "))

sp = cp * (1 + profit_percent / 100)

print("The Selling Price (SP) is:", sp)

 

53. Calculate selling price  where loss percentage and cost price is given

cp = float(input("Enter the Cost Price (CP): "))

loss_percent = float(input("Enter the Loss Percentage: "))

sp = cp * (1 - loss_percent / 100)

print("The Selling Price (SP) is:", sp)

 

54. Calculate cost price  where loss percentage and selling price is given

sp = float(input("Enter the Selling Price (SP): "))

loss_percent = float(input("Enter the Loss Percentage: "))

cp = sp / (1 - loss_percent / 100)

print("The Cost Price (CP) is:", cp)

 

55. Calculate cost price  where profit percentage and selling price is given

sp = float(input("Enter the Selling Price (SP): "))

profit_percent = float(input("Enter the Profit Percentage: "))

cp = sp / (1 + profit_percent / 100)

print("The Cost Price (CP) is:", cp)


Python Program Collection 03 - to display tsa, volume of sphere, hemisphere, cylinder, cuboid, cube

 


28. Display total surface area of sphere.

pi = 3.1416

r = float(input("Enter the radius of the sphere: "))

area = 4 * pi * r ** 2

print(f"The total surface area of the sphere with radius {r} is: {area:.2f}")

 

 

 

 

29. Display volume of sphere.

r = float(input("Enter the radius of the sphere: "))

pi = 3.1416

volume = (4/3) * pi * r ** 3

print(f"The volume of the sphere with radius {r} is: {volume:.2f}")

 

30. Display total surface area and volume of sphere.

r = float(input("Enter the radius of the sphere: "))

surface_area = 4 * (22/7) * r ** 2

volume = (4/3) * (22/7) * r ** 3

print(f"The total surface area of the sphere with radius {r} is: {surface_area:.2f}")

print(f"The volume of the sphere is: {volume:.2f}")

 

31. Display total surface area of hemisphere.

r = float(input("Enter the radius of the hemisphere: "))

tsa  = 3 * (22/7) * r ** 2

print(f"The total surface area of the hemisphere is: {tsa:.2f}")

 

32. Display volume of hemisphere.

r = float(input("Enter the radius of the hemisphere: "))

volume = (2/3) * (22/7) * r ** 3

print(f"The volume of the hemisphere with radius {r} is: {volume:.2f}")

 

33. Display total surface area and volume of hemisphere.

r = float(input("Enter the radius of the hemisphere: "))

TSA = 3 * (22/7) * r ** 2

volume = (2/3) * (22/7) * r ** 3

print(f"The total surface area of the hemisphere is: {TSA:.2f}")

print(f"The volume of the hemisphere is: {volume:.2f}")

 

34. Display total surface area of cylinder.

r = float(input("Enter the radius of the cylinder: "))

h = float(input("Enter the height of the cylinder: "))

TSA = 2 * (22/7) * r * (h + r)

print(f"The total surface area of the cylinder is: {TSA:.2f}")

 

35. Display volume of cylinder.

r = float(input("Enter the radius of the cylinder: "))

h = float(input("Enter the height of the cylinder: "))

volume = (22/7) * r ** 2 * h

print(f"The volume of the cylinder is: {volume:.2f}")

 

36. Display total surface area and volume of cylinder.

r = float(input("Enter the radius of the cylinder: "))

h = float(input("Enter the height of the cylinder: "))

TSA = 2 * (22/7) * r * (h + r)

volume = (22/7) * r ** 2 * h

print(f"The total surface area of the cylinder is: {TSA:.2f}")

print(f"The volume of the cylinder is: {volume:.2f}")

 

37. Display total surface area of cuboid / box.

l = float(input("Enter the length of the cuboid: "))

b = float(input("Enter the breadth of the cuboid: "))

h = float(input("Enter the height of the cuboid: "))

TSA = 2 * (l*b + b*h + h*l)

print(f"The total surface area of the cuboid is: {TSA:.2f}")

 

38. Display volume of cuboid / box.

l = float(input("Enter the length of the cuboid: "))

b = float(input("Enter the breadth of the cuboid: "))

h = float(input("Enter the height of the cuboid: "))

volume = l * b * h

print(f"The volume of the cuboid is: {volume:.2f}")

 

39. Display total surface area and volume of cuboid.

l = float(input("Enter the length of the cuboid: "))

b = float(input("Enter the breadth of the cuboid: "))

h = float(input("Enter the height of the cuboid: "))

TSA = 2 * (l*b + b*h + h*l)

volume = l * b * h

print(f"The total surface area of the cuboid is: {TSA:.2f}")

print(f"The volume of the cuboid is: {volume:.2f}")

 

40. Display total surface area of cube.

a = float(input("Enter the side of the cube: "))

TSA = 6 * a ** 2

print(f"The total surface area of the cube with side {a} is: {TSA:.2f}")

 

41. Display volume of cube

a = float(input("Enter the side of the cube: "))

volume = a ** 3

print(f"The volume of the cube with side {a} is: {volume:.2f}")

 

42. Display total surface area and volume of cube.

a = float(input("Enter the side of the cube: "))

TSA = 6 * a ** 2

volume = a ** 3

print(f"The total surface area of the cube with side {a} is: {TSA:.2f}")

print(f"The volume of the cube with side {a} is: {volume:.2f}")

Python Program Collection 02 - to display area, perimeter of rectangle, square, circle, triangle, area of 4 walls

 



Python Program Collection 02 - to display area, perimeter of rectangle, square, circle, triangle, area of 4 walls

15. Display area of rectangle.

length = int(input("Enter the length of rectangle: "))

breadth = int(input("Enter the breadth of rectangle: "))

area = length * breadth

print(f"Area of rectangle with length {length} and breadth {breadth} is {area}")

 

16. Display area of square.

side = int(input("Enter the side of the square: "))

area = side ** 2

print(f"Area of square with side {side} is {area}")

 

17. Display area of circle.

radius = float(input("Enter the radius of the circle: "))

area = 22 / 7 * (radius ** 2)

print(f"Area of circle with radius {radius} is {area}")

 

18. Display perimeter of rectangle.

length = int(input("Enter the length of rectangle: "))

breadth = int(input("Enter the breadth of rectangle: "))

perimeter = 2 * (length + breadth)

print(f"Perimeter of rectangle = {perimeter}")

 

19. Display perimeter of square.

side = int(input("Enter the side of the square: "))

perimeter = 4 * side

print(f"Perimeter of square with side {side} is {perimeter}")

 

20. Display circumference of circle.

radius = float(input("Enter the radius of the circle: "))

circumference = 2 * (22 / 7) * radius

print(f"Circumference of circle with radius {radius} is {circumference}")

 

21. Display area and perimeter of rectangle.

length = int(input("Enter the length of rectangle: "))

breadth = int(input("Enter the breadth of rectangle: "))

area = length * breadth

perimeter = 2 * (length + breadth)

print(f"Area of rectangle is {area}")

print(f"Perimeter of rectangle is {perimeter}")

 

22. Display area and perimeter of square.

side = int(input("Enter the side of the square: "))

area = side * side       

perimeter = 4 * side

print(f"Area of square with side {side} is {area}")

print(f"Perimeter of square with side {side} is {perimeter}")

 

23. Display area and circumference of circle.

radius = float(input("Enter the radius of the circle: "))

area = 22 / 7 * (radius ** 2)

circumference = 2 * 22 / 7 * radius

print(f"Area of circle with radius {radius} is {area}")

print(f"Circumference of circle with radius {radius} is {circumference}")

 

24. Display area of 4 walls.

length = float(input("Enter the length of the room: "))

breadth = float(input("Enter the breadth of the room: "))

height = float(input("Enter the height of the room: "))

area_walls = 2 * (length + breadth) * height

print(f"Area of 4 walls of room is {area_walls}")

 

25. Display area of triangle.

base = float(input("Enter the base of the triangle: "))

height = float(input("Enter the height of the triangle: "))

area = 0.5 * base * height

print(f"Area of triangle with base {base} and height {height} is {area}")

 

26. Display area of parallelogram.

base = float(input("Enter the base of the parallelogram: "))

height = float(input("Enter the height of the parallelogram: "))

area = base * height

print(f"Area of parallelogram is {area}")

 

27. Display area of triangle when three sides are given.

a = float(input("Enter first side of the triangle: "))

b = float(input("Enter second side of the triangle: "))

c = float(input("Enter third side of the triangle: "))

s = (a + b + c) / 2  

area = (s * (s - a) * (s - b) * (s - c)) ** 0.5  

print(f"Area of triangle with sides {a}, {b}, {c} is {area}")