- Write a program to accept two integers and calculate their sum.
- Write a program that accepts the radius of a circle and prints its area.
- Write a program that accepts base and height and calculate the area of a triangle.
- Write a program to compute the area of square.
- Write a program to calculate simple interest.
- Write a program to read two numbers and prints their quotient and reminder.
- Write a program that inputs a student’s marks in three subjects (out of 100) and prints the percentage marks.
SOLUTION
#1 Write a program to accepts two integers and print their sum.
a=int(input("Enter the first integer:"))
b=int(input("Enter the second integer:"))
sum=a+b
print("The sum of two integers are:", sum)
sum=a+b
print("The sum of two integers are:", sum)
#2 Write a program that accepts radius of a circle and prints its area.
r=int(input("Enter the radius of circle:"))
area=3.14*r**2
print("The area of the circle is:", area)
area=3.14*r**2
print("The area of the circle is:", area)
#3 Write a program that accepts base and height and calculate the area of triangle
b=float(input("Enter the base of triangle:"))
h=float(input("Enter the height of triangle:"))area=(1/2)*b*h
print("The area of triangle is:", area)
#4 Write a program to compute area of square.
a=float(input("Enter the value of side:"))
area_sq=a**2
print("The area of square is:", area_sq)
#5 Write a program to calculate simple interest.
p=float(input('Enter the principal amount in : '))
r=float(input('Enter the rate of interest: '))
t=float(input('Enter the time in years: '))
si=(p*r*t)/100
print('The simple interest is : ', si)
#6 Write a program to read two numbers and prints their quotient and reminder
a=float(input("Enter the dividend:"))b=float(input("Enter the divisor:"))
q=a//b
r=a%b
print("The quotient is:", q)
print("The remainder is:", r)
#7 Write a program that inputs a student’s marks in three subjects (out of 100)and prints the percentage marks
print("Enter the marks of three subject out of 100")a=float(input("Enter the marks of first subject:"))
b=float(input("Enter the marks of second subject:"))
c=float(input("Enter the marks of third subject:"))
p=(a+b+c)/3
print("The percentage marks are:", p,"%")

0 Comments