0% found this document useful (0 votes)
13 views4 pages

Python Programs

The document provides a list of Python programs for practical exams, including calculations for area, perimeter, marks, simple interest, and eligibility to vote. It also includes coding examples for basic arithmetic operations, checking odd/even numbers, and printing sequences using loops. The programs are designed to help students practice fundamental programming concepts in Python.

Uploaded by

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

Python Programs

The document provides a list of Python programs for practical exams, including calculations for area, perimeter, marks, simple interest, and eligibility to vote. It also includes coding examples for basic arithmetic operations, checking odd/even numbers, and printing sequences using loops. The programs are designed to help students practice fundamental programming concepts in Python.

Uploaded by

mahirenurawat123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

Subject : AI

Programs List of Python for Practical File/ Exam

1. To calculate the area and perimeter of a rectangle


2. To calculate the total marks and average marks of a student in 5 subjects.
3. To calculate the simple interest by taking the value of P,R & T from user
4. To find out whether a person to eligible to vote or not.
5. To find out a number is Odd or Even
6. To insert 2 number and find out the greater number among them.
7. To print first 10 natural numbers using for loop
8. To print even numbers 2 to 20 using for loop.
9. To print odd numbers 1 to 20 using for loop.
10. To print numbers in reverse order 10 to 1 using for loop.

Coding for the programs

1. Add, Subtract, Multiply, and Divide Two Numbers

a = int(input("Enter first number: "))


b = int(input("Enter second number: "))

print("Addition:", a + b)
print("Subtraction:", a - b)
print("Multiplication:", a * b)
print("Division:", a / b)

2. Calculate Area and Perimeter of a Rectangle

length = float(input("Enter length of rectangle: "))


breadth = float(input("Enter breadth of rectangle: "))

area = length * breadth


perimeter = 2 * (length + breadth)

print("Area of rectangle:", area)


print("Perimeter of rectangle:", perimeter)

3. Calculate Total and Average Marks of a Student

sub1 = float(input("Enter marks of Subject 1: "))


sub2 = float(input("Enter marks of Subject 2: "))
sub3 = float(input("Enter marks of Subject 3: "))
sub4 = float(input("Enter marks of Subject 4: "))
sub5 = float(input("Enter marks of Subject 5: "))

total = sub1 + sub2 + sub3 + sub4 + sub5


average = total / 5

print("Total Marks =", total)


print("Average Marks =", average)

4. Calculate Simple Interest

P = float(input("Enter Principal amount: "))


R = float(input("Enter Rate of interest: "))
T = float(input("Enter Time in years: "))

SI = (P * R * T) / 100
print("Simple Interest =", SI)

5. Use Floor Division and Modulus Operator

a = int(input("Enter first number: "))


b = int(input("Enter second number: "))

print("Floor Division:", a // b)
print("Remainder (Modulus):", a % b)
6. Check Eligibility to Vote

age = int(input("Enter your age: "))

if age >= 18:


print("You are eligible to vote.")
else:
print("You are not eligible to vote.")

7. Check Whether a Number is Odd or Even

num = int(input("Enter a number: "))

if num % 2 == 0:
print("Even Number")
else:
print("Odd Number")

8. Check Divisibility by 5

num = int(input("Enter a number: "))

if num % 5 == 0:
print("Number is divisible by 5.")
else:
print("Number is not divisible by 5.")

9. Find Greater Number Among Two

a = int(input("Enter first number: "))


b = int(input("Enter second number: "))

if a > b:
print("First number is greater.")
elif b > a:
print("Second number is greater.")
else:
print("Both numbers are equal.")

10. Print First 10 Natural Numbers (Using For Loop)


for i in range(1, 11):
print(i)

11. Print Even Numbers from 2 to 20 (Using For Loop)

for i in range(2, 21, 2):


print(i)

12. Print Odd Numbers from 1 to 20 (Using For Loop)

for i in range(1, 21, 2):


print(i)

13. Print Numbers in Reverse Order from 10 to 1 (Using For Loop)

for i in range(10, 0, -1):


print(i)

14. Print Even Numbers from 20 to 1 (Using While Loop)

i = 20
while i >= 2:
print(i)
i = i-2

15. Print Odd Numbers from 19 to 1 (Using While Loop)

i = 19
while i >= 1:
print(i)
i = i-2

You might also like