0% found this document useful (0 votes)
4 views3 pages

Python Practical File

The document contains a practical file for Python programming with various exercises. It includes calculations for average and grade of marks, sale price after discount, area and perimeter of a rectangle, simple interest, profit or loss, finding the largest and smallest numbers in a list, third largest number, sum of squares of the first 100 natural numbers, counting vowels in a string, and first 10 multiples of a number. Each exercise is accompanied by code snippets demonstrating the implementation.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Python Practical File

The document contains a practical file for Python programming with various exercises. It includes calculations for average and grade of marks, sale price after discount, area and perimeter of a rectangle, simple interest, profit or loss, finding the largest and smallest numbers in a list, third largest number, sum of squares of the first 100 natural numbers, counting vowels in a string, and first 10 multiples of a number. Each exercise is accompanied by code snippets demonstrating the implementation.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Python Programming Practical File

1. Average and Grade of Marks


m1 = float(input("Enter marks 1: "))
m2 = float(input("Enter marks 2: "))
m3 = float(input("Enter marks 3: "))

avg = (m1 + m2 + m3) / 3


print("Average =", avg)

if avg >= 90:


print("Grade A")
elif avg >= 75:
print("Grade B")
elif avg >= 50:
print("Grade C")
else:
print("Fail")

2. Sale Price After Discount


cost = float(input("Enter cost price: "))
discount = float(input("Enter discount %: "))

sale_price = cost - (cost * discount / 100)


print("Sale Price =", sale_price)

3. Area and Perimeter of Rectangle


l = float(input("Enter length: "))
b = float(input("Enter breadth: "))

area = l * b
perimeter = 2 * (l + b)

print("Area =", area)


print("Perimeter =", perimeter)

4. Simple Interest
p = float(input("Enter principal: "))
r = float(input("Enter rate: "))
t = float(input("Enter time: "))
si = (p * r * t) / 100
print("Simple Interest =", si)

5. Profit or Loss
cp = float(input("Enter cost price: "))
sp = float(input("Enter selling price: "))

if sp > cp:
print("Profit =", sp - cp)
else:
print("Loss =", cp - sp)

6. Largest and Smallest Number in List


numbers = [12, 45, 7, 89, 23]

print("Largest =", max(numbers))


print("Smallest =", min(numbers))

7. Third Largest Number


nums = [10, 25, 40, 5, 30]
[Link]()

print("Third largest =", nums[-3])

8. Sum of Squares of First 100 Natural Numbers


sum = 0
for i in range(1, 101):
sum += i * i

print("Sum of squares =", sum)

9. Count Vowels in a String


text = input("Enter a string: ")
count = 0

for ch in text:
if [Link]() in "aeiou":
count += 1

print("Number of vowels =", count)

10. First 10 Multiples of a Number


n = int(input("Enter a number: "))
for i in range(1, 11):
print(n, "x", i, "=", n * i)

You might also like