You are on page 1of 3

PROGRAMS

Exercise - 1

1. Write a program to add two numbers.


a=int(input('Enter first number '))
b=int(input('Enter second number '))
c=a+b
print('The sum is',c)

2. Write a program to input a number and calculate its square.


a=int(input('Enter a number '))
b=a*a
print('The square is ',b)

3. Write a program to input radius of a circle and calculate its area and circumference.
r=float(input('Enter a number '))
area=3.14*r*r
cir=2*3.14*r
print('The area is ',area)
print('The circumference is',cir)

4. Write a program to accept three numbers as input and display their sum, product and
average.
a=int(input('Enter first number '))
b=int(input('Enter second number '))
c=int(input('Enter third number '))
s=a+b+c
p=a*b*c
av=s/3
print('The sum is ',s)
print('The product is ',p)
print('The average is ',av)

5. Write a PYTHON program to input length and breadth of a rectangle and display the
area and perimeter.
l=int(input('Enter length '))
b=int(input('Enter breadth '))
a=l*b
p=2*(l+b)
print('The area is ',a)
print('The perimeter is ',p)

6. Write a program to input marks of five subjects and calculate the total and percentage.
e=int(input('Enter marks in English '))
h=int(input('Enter marks in Hindi '))
m=int(input('Enter marks in Maths '))
s=int(input('Enter marks in Science '))
ss=int(input('Enter marks in SST '))
t=e+h+m+s+ss
p=t/500*100
print('The total is ',t)
print('The percentage is',p)

7. Write a program to input three sides of a triangle and calculate the area.
import math
a=float(input("enter first side"))
b=float(input("enter second side"))
c=float(input("enter third side"))
s=(a+b+c)/2
area=math.sqrt(s*(s-a)*(s-b)*(s-c))
print("The area is ",area)

8. Write a program to input principal, rate and time and calculate the compound interest.
A=p*(1+r/100)t
I=A-p
import math

p=float(input("enter Principal "))


r=float(input("enter rate of interest "))
t=float(input("enter time in years "))
a=p*math.pow((1+r/100),t)
i=a-p
print("The interest is ",i)
print("The amount is ",a)

9. Write a PYTHON program to input the cost price and selling price of a product and
calculate the profit or loss.
cp=float(input("enter Cost Price "))
sp=float(input("enter Selling Price "))

p=sp-cp
print("The profit is ",p)

10. Write a PYTHON program to input a number and display the square and cube of that
number.

11. Write a PYTHON program to input temperature in Fahrenheit and convert in to


centigrade.
c = (5.0/9)*(f-32)

12. Write a program to read the number of seconds and print it in the form mins and
seconds. Eg: 200 seconds should be printed as 3 mins and 20 seconds.
a=int(input("enter the no. of seconds"))
m=a//60
s=a%60
print(m, " minutes and ",s, " seconds")

13. Write a program to find sum of two distances with feet and inches.

14. Write a program to swap two numbers.

15. Write a program to add two complex numbers.

You might also like