You are on page 1of 3

Adeena Shuja 2022F-SE-202 SECTION:(E)

OBJECTIVE:

Implement different type of data types, variables and operators used in Python.

1. Write a program that calculates area of a circle A=π r 2 . (Consider r = 50).

Code:

radius=50
pi=3.142
#compute the area
area=pi*(radius*radius)
print("the area of circle is",area)

Output:

2. Write a program that performs the following four operations and prints their result on the
screen.

Code:
50+4
50-4
50*4
50/4
A=50
B=4
#FOR ADDITION
#FOR SUBTRACTION
#FOR MULTIPLICATION
#FOR DIVISON
C=A+B
D=A-B
Adeena Shuja 2022F-SE-202 SECTION:(E)

E=A*B
F=A/B
print("the addition of two number is",C)
print("the subtraction of two number is",D)
print("the multiplicatioin of two number is",E)
print("the dividion of two number is",F)

Output:

3. Write a Python program to convert height (in feet and inches) to centimeters.
Convert the height of 5 feet 2 inches to centimeters.

 First, convert 5 feet to inches: 5 feet × 12 inches/foot = 60 inches


 Add up our inches: 60 + 2 = 62 inches
 Convert inches to cm: 62 inches × 2.54 cm/inch = 157.48 cm

Code:

#program to change height from feet and inches to cm.

height_f=5

height_in=2

h_feet=height_f*12

h_inch=height_in+h_feet

h_cm=h_inch*2.54

print('your height in centimeter is',h_cm)

Output:
Adeena Shuja 2022F-SE-202 SECTION:(E)

4. Write a program to compute distance between two points by creating variables


(Pythagorean Theorem)
Distance =((x2−x1)^2+(y2−y1)^2)^1/2

Code:
#calculating distance between two points.
X1=input('please enter the value of X1\n')
X1=int(X1)
X2=input('please enter the value of X2\n')
X2=int(X2)
Y1=input('please enter the value of Y1\n')
Y1=int(Y1)
Y2=input('please enter the value of Y2')
Y2=int(Y2)
d=(((X2-X1)**2)+((Y2-Y1)**2))**0.5
#to do square root use decimel power for eg. 1/2 power is 0.5
print('the distance is',d)

Output:

You might also like