You are on page 1of 10

1.

Write a python program to add two 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 to add two calculate the avarage of three
numbers :
Code:
x=float(input("1st number: "))
y=float(input("2nd number: "))
z=float(input("3rd number: "))
sum=x+y+z
avarage=sum/3
print("the avarage is " , avarage )
Output:
3.Write a python program to add two calculate the area of a triangle using
½*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 two 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:
7.write a python program to convert Celsius
temperature to Fahrenheit temperature:
Code:
c=float(input("temparature in celcius: "))
temparature_farenhite=(c*(9/5))+32
print("temparature in Farenhite is = " , temparature_farenhite)
Output:
8..write a python program to convert Fahrenheit
temperature to Fahrenheit Celsius:
Code:
f=float(input("temparature infarenhite: "))
temparature_celcius=(f-32)*(5/9)
print("temparature in Calcius 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 :
10.Write a python program to ceil , round and
floor a 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