Professional Documents
Culture Documents
OBJECTIVE:
Implement different type of data types, variables and operators used in Python.
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.
Code:
height_f=5
height_in=2
h_feet=height_f*12
h_inch=height_in+h_feet
h_cm=h_inch*2.54
Output:
Adeena Shuja 2022F-SE-202 SECTION:(E)
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: