Practical - 2-2
Practical - 2-2
Note : Write the theory on types of operators in python with all the charts.
Then write the given below programs with output
1. Write a program to simulate a simple calculator (+ - / * %) that takes two operands as input and displays
the result.
2. Write a program to find area and perimeter of geometric objects.
3. The distance between two cities (in km.) is input through the keyboard. Write a program to convert and
print this distance in meters, feet, inches and centimeters.
4. Write a Program to interchange two numbers.
5. Write a program to compute Fahrenheit from centigrade
# 1 . Program to demonstrate a calculator
1. Add
2. Subtract
3. Multiply
4. Divide
6 - 4 = 2
____________________________________________________________________________
OUTPUT -1
OUTPUT
OUTPUT
Distance in cm : 100000.0032
# 4 . Write a Program to interchange two numbers.
t=x
x=y
y=t
OUTPUT
Before swapping :
x = 10 y = 20
After swapping :
x = 20 y = 10
# 5 .Write a program to compute Fahrenheit from centigrade
c=float(input("Enter temperature in celcius : "))
f=(c*1.8)+32
print("Temperature in fahrenheit : ",f)
OUTPUT
Enter temperature in celcius : 32
Temperature in fahrenheit : 89.6