Class XII Federal Board – Python Practical Programs
SLO CS-11-C-01: Write and execute simple programs using variables, operators, and input/output
handling.
1. Addition of Two Numbers
a = int(input("Enter first number: ")) b = int(input("Enter second number: ")) sum = a + b print("Sum
=", sum)
2. Area of Rectangle
length = int(input("Enter length: ")) width = int(input("Enter width: ")) area = length * width print("Area
=", area)
3. Simple Interest
p = int(input("Enter principal: ")) r = int(input("Enter rate: ")) t = int(input("Enter time: ")) si = (p * r * t)
/ 100 print("Simple Interest =", si)
4. Average of Three Numbers
a = int(input("Enter first number: ")) b = int(input("Enter second number: ")) c = int(input("Enter third
number: ")) avg = (a + b + c) / 3 print("Average =", avg)
5. Celsius to Fahrenheit
c = int(input("Enter Celsius: ")) f = (c * 9 / 5) + 32 print("Fahrenheit =", f)
6. Salary with Bonus
salary = int(input("Enter salary: ")) bonus = int(input("Enter bonus: ")) total = salary + bonus
print("Total Salary =", total)
7. Find Remainder
a = int(input("Enter dividend: ")) b = int(input("Enter divisor: ")) rem = a % b print("Remainder =",
rem)
8. Total Marks and Percentage
m1 = int(input("Enter marks 1: ")) m2 = int(input("Enter marks 2: ")) m3 = int(input("Enter marks 3:
")) total = m1 + m2 + m3 percent = (total / 300) * 100 print("Total =", total) print("Percentage =",
percent)
9. Swap Two Numbers
a = int(input("Enter first number: ")) b = int(input("Enter second number: ")) a, b = b, a print("a =", a)
print("b =", b)
10. Electricity Bill
units = int(input("Enter units: ")) rate = int(input("Enter rate: ")) bill = units * rate print("Bill =", bill)
11. Square of a Number
num = int(input("Enter number: ")) square = num * num print("Square =", square)
12. Rupees to Dollars
rupees = int(input("Enter rupees: ")) rate = 280 dollars = rupees / rate print("Dollars =", dollars)
13. Speed Calculation
distance = int(input("Enter distance: ")) time = int(input("Enter time: ")) speed = distance / time
print("Speed =", speed)
14. Discounted Price
price = int(input("Enter price: ")) discount = int(input("Enter discount %: ")) final = price - (price *
discount / 100) print("Final Price =", final)
15. Minutes to Hours
minutes = int(input("Enter minutes: ")) hours = minutes / 60 print("Hours =", hours)