0% found this document useful (0 votes)
6 views2 pages

Python Programs for Average, Sale Price, Area

The document contains practical Python programs demonstrating calculations for average and grade, sale price, and geometric properties. It includes code snippets and their corresponding outputs for each program. Key outputs include an average mark of 82.6 with a grade of B, a sale price of 800.0, and various area and perimeter values for different shapes.
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)
6 views2 pages

Python Programs for Average, Sale Price, Area

The document contains practical Python programs demonstrating calculations for average and grade, sale price, and geometric properties. It includes code snippets and their corresponding outputs for each program. Key outputs include an average mark of 82.6 with a grade of B, a sale price of 800.0, and various area and perimeter values for different shapes.
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

Python Practical Programs with Output

1. Average and Grade


Code:
marks = [78, 85, 90, 72, 88]
average = sum(marks) / len(marks)

if average >= 90:


grade = 'A'
elif average >= 75:
grade = 'B'
elif average >= 60:
grade = 'C'
else:
grade = 'D'

print(f"Average Marks: {average}")


print(f"Grade: {grade}")
Output:
Average Marks: 82.6
Grade: B

2. Sale Price Calculation


Code:
cost = 1000
discount = 20
sale_price = cost - (cost * discount / 100)
print(f"Sale Price: {sale_price}")
Output:
Sale Price: 800.0

3. Perimeter and Area


Code:
import math
a, b, c = 5, 6, 7
s = (a + b + c) / 2
area_triangle = [Link](s * (s - a) * (s - b) * (s - c))
perimeter_triangle = a + b + c
side = 4
area_square = side ** 2
perimeter_square = 4 * side
radius = 3
area_circle = [Link] * radius ** 2
circumference_circle = 2 * [Link] * radius

print(f"Triangle: Area={area_triangle}, Perimeter={perimeter_triangle}")


print(f"Square: Area={area_square}, Perimeter={perimeter_square}")
print(f"Circle: Area={area_circle}, Circumference={circumference_circle}")
Output:
Triangle: Area=14.6969, Perimeter=18
Square: Area=16, Perimeter=16
Circle: Area=28.2743, Circumference=18.8495

You might also like