Computer Application Lab Assignment Date: 27.09.
24
ADAMAS UNIVERSITY
SCHOOL OF ENGINEERING & TECHNOLOGY
PYTHON PROGRAM
1. Write a program in python to print addition of two numbers. (Take user input)
Code:
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
c=a+b
print("The addition is", c)
Output:
Enter first number: 10
Enter second number: 20
The addition is 30
2. Write a program in python to find the addition & average of three float numbers.
Code:
a = float(input("Enter first number: "))
b = float(input("Enter second number: "))
c = float(input("Enter third number: "))
sum = a + b + c
avg = sum / 3
print("Addition is", sum)
print("Average is", avg)
Output:
Enter first number: 2.5
Enter second number: 3.5
Enter third number: 4.0
Addition is 10.0
Average is 3.3333333333333335
3. Write a program in python to find the area and circumference of a circle.
Code:
r = float(input("Enter the radius: "))
pi = 3.14
area = pi * r * r
circumference = 2 * pi * r
print("Area of the circle is", area)
print("Circumference of the circle is", circumference)
Output:
Enter the radius: 7
Area of the circle is 153.86
Circumference of the circle is 43.96
4. Write a program in python to find the area of a rectangle.
Code:
length = float(input("Enter the length: "))
breadth = float(input("Enter the breadth: "))
area = length * breadth
print("Area of the rectangle is", area)
Output:
Enter the length: 5
Enter the breadth: 4
Area of the rectangle is 20.0
5. Write a program in python to compute Simple Interest.
Code:
p = float(input("Enter principal amount: "))
r = float(input("Enter rate of interest: "))
t = float(input("Enter time (in years): "))
si = (p * r * t) / 100
print("Simple Interest is", si)
Output:
Enter principal amount: 1000
Enter rate of interest: 5
Enter time (in years): 2
Simple Interest is 100.0