0% found this document useful (0 votes)
34 views11 pages

Physics

The document contains 10 code snippets that demonstrate how to write Python programs to perform basic mathematical calculations and conversions. The programs calculate sums, averages, areas of shapes, temperature conversions, number swapping, and rounding functions. For each problem, the code, inputs/outputs, and purpose are clearly explained.

Uploaded by

soadabedinsiam
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)
34 views11 pages

Physics

The document contains 10 code snippets that demonstrate how to write Python programs to perform basic mathematical calculations and conversions. The programs calculate sums, averages, areas of shapes, temperature conversions, number swapping, and rounding functions. For each problem, the code, inputs/outputs, and purpose are clearly explained.

Uploaded by

soadabedinsiam
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
You are on page 1/ 11

‭L-1|T-1‬

‭MDM-101‬

‭Lab Report-01‬

‭ xperiment date :26.11.2023‬


E
‭Submited by:MD.Soad Abedin Siam‬
‭Wpe:23010301042‬
‭Submited to:Sultana Umme Habiba‬
‭1.Write a python program to calculate the sum of two numbers :‬
‭Code:‬
‭x=float(input("Enter your 1st number:"))‬
‭y=float(input("Enter your 2nd number:"))‬
‭sum=x+y‬
‭print("sum of the two number is" , sum)‬
‭Output:‬
‭2.Write a python program calculate the average of three numbers :‬

‭Code:‬
‭x=float(input("1st number: "))‬
‭y=float(input("2nd number: "))‬
‭z=float(input("3rd number: "))‬
‭sum=x+y+z‬
‭average=sum/3‬
‭print("the average is " , average )‬
‭Output:‬
‭ .Write a python program to calculate the area of a triangle using‬
3
‭½*base*height:‬
‭Code:‬
‭x=float(input("Enter base of the triangle: "))‬
‭y=float(input("Enter height of the triangle:"))‬
‭area=0.5*x*y‬
‭print("the area of the triangle is=" , area)‬
‭Output:‬
‭4.Write a python program to calculate the area of a triangle‬
‭using three sides:‬
‭Code:‬
‭x = float(input("Enter the first side of the triangle: "))‬
‭y = float(input("Enter the second side of the triangle "))‬
‭z = float(input("Enter the trird side of the triangle "))‬
‭s = (x+y+z)/2‬
‭area = (s*(s-x)*(s-y)*(s-z))‬
‭print("the area of the triangle is = " , area)‬
‭Output:‬
‭5.Write a python program to calculate the area of a rectangle:‬
‭Code:‬
‭length = float(input("Enter the length: "))‬
‭width = float(input("Enter width: "))‬
‭area= length*width‬
‭print("the area of the rectangle is = " , area)‬
‭Output:‬
‭6.Write a python program to calculate the area of a circle:‬
‭Code:‬
‭radious = float(input("Enter the radious: "))‬
‭area= 3.1416*radious*radious‬
‭print("the area of the rectangle is = " , area)‬
‭Output:‬
‭ .write a python program to convert Celsius temperature to‬
7
‭Fahrenheit temperature:‬
‭Code:‬
‭c=float(input("temperature in celsius: "))‬
‭temparature_farenhite=(c*(9/5))+32‬
‭print("temperature in Fahrenheit is = " , temparature_farenhite)‬
‭Output:‬
‭ ..write a python program to convert Fahrenheit temperature‬
8
‭to Celsius temperature :‬
‭Code:‬
‭f=float(input("temperature in fahrenheit: "))‬
‭temparature_celcius=(f-32)*(5/9)‬
‭print("temperature in Celsius is = " , temparature_celcius)‬
‭Output:‬
‭9.Write a python program to swap two numbers:‬

‭Code:‬
‭x=int(input("Enter 1st number:"))‬
‭y=int(input("Enter 2nd number:"))‬
‭x,y=y,x‬
‭print("1st number is" ,x)‬
‭print("2nd number is" ,y)‬
‭Output :‬
‭ 0.Write a python program to ceil , round and floor a‬
1
‭floating-point number:‬
‭Code:‬

‭x=float(input("Enter your floating number:"))‬


‭import math‬
‭a=math.ceil(x)‬
‭b=round(x)‬
‭c=math.floor(x)‬
‭print("ceil="+ str(a))‬
‭print("round="+ str(b))‬
‭print("floor=" + str(c))‬

‭Output:‬

You might also like