Python Practical Programs with Outputs
Program 1: 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
Program 2: Area of a Circle
import math
radius = float(input("Enter the radius of the circle: "))
area = [Link] * radius ** 2
print("Area of the circle:", area)
Sample Output:
Enter the radius of the circle: 3
Area of the circle: 28.274333882308138
Program 3: 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
Program 4: Percentage Calculation
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