0% found this document useful (0 votes)
3 views

Python_Practical_Programs_Complete

The document contains practical Python programs that demonstrate basic calculations, including the sum of two integers, area of a circle, area of a triangle, percentage of marks, area of a square, and simple interest. Each program includes sample input and output to illustrate functionality. The programs utilize basic input and mathematical operations to achieve their objectives.

Uploaded by

arnavb0902
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Python_Practical_Programs_Complete

The document contains practical Python programs that demonstrate basic calculations, including the sum of two integers, area of a circle, area of a triangle, percentage of marks, area of a square, and simple interest. Each program includes sample input and output to illustrate functionality. The programs utilize basic input and mathematical operations to achieve their objectives.

Uploaded by

arnavb0902
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Python Practical Programs

1. Write a program to accept two integers and print their sum.

# This program calculates the sum of two integers.


a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
print("Sum:", a + b)

Sample Output:
Enter first number: 5
Enter second number: 7
Sum: 12

2. Write a program that accepts the radius of a circle and prints its area.

# This program calculates the area of a circle given the radius.


import math
radius = float(input("Enter the radius of the circle: "))
area = math.pi * radius ** 2
print("Area of the circle:", area)

Sample Output:
Enter the radius of the circle: 3
Area of the circle: 28.27

3. Write a program that accepts base and height and calculates the area of a triangle.

# This program calculates the area of a triangle.


base = float(input("Enter base of the triangle: "))
height = float(input("Enter height of the triangle: "))
area = 0.5 * base * height
print("Area of the triangle:", area)

Sample Output:
Enter base of the triangle: 10
Enter height of the triangle: 5
Area of the triangle: 25.0

4. Write a program that inputs a student's marks in three subjects (out of 100) and prints the percen

# This program calculates the percentage of marks in three subjects.


Python Practical Programs

marks1 = float(input("Enter marks in subject 1: "))


marks2 = float(input("Enter marks in subject 2: "))
marks3 = float(input("Enter marks in subject 3: "))
percentage = (marks1 + marks2 + marks3) / 3
print("Percentage marks:", percentage)

Sample Output:
Enter marks in subject 1: 85
Enter marks in subject 2: 90
Enter marks in subject 3: 80
Percentage marks: 85.0

5. Write a program to compute the area of square and triangle.

# This program calculates the area of a square and a triangle.


side = float(input("Enter the side of the square: "))
area_square = side ** 2
print("Area of the square:", area_square)

base = float(input("Enter base of the triangle: "))


height = float(input("Enter height of the triangle: "))
area_triangle = 0.5 * base * height
print("Area of the triangle:", area_triangle)

Sample Output:
Enter the side of the square: 4
Area of the square: 16.0
Enter base of the triangle: 10
Enter height of the triangle: 5
Area of the triangle: 25.0

6. Write a program to calculate simple interest.

# This program calculates simple interest.


principal = float(input("Enter principal amount: "))
rate = float(input("Enter annual interest rate (in %): "))
time = float(input("Enter time in years: "))
simple_interest = (principal * rate * time) / 100
print("Simple Interest:", simple_interest)
Python Practical Programs

Sample Output:
Enter principal amount: 1000
Enter annual interest rate (in %): 5
Enter time in years: 2
Simple Interest: 100.0

You might also like