Subodh Public School, Rambagh
(A Senior Secondary Co-Educational CBSE Affiliated School)
Session : 2025-26
Estd. 1985 Department of Computer
Chapter: Python
Programs
Subject : Artificial Intelligence Class : Flyers-1 (IX)
1. Python program to add two numbers
num1 = 15
num2 = 12
# Adding two nos
sum = num1 + num2
# printing values
print("Sum of", num1, "and", num2 , "is", sum)
2. Maximum of two numbers in Python
# Python program to return maximum of two numbers
# Getting input from user
num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
# printing the maximum value
if(num1 > num2):
print(num1, "is greater")
elif(num1 < num2):
print(num2, "is greater")
else:
print("Both are equal")
3. Program to find area and perimeter of a circle
# Python program to find the
# area and perimeter of circle in python
# Initialising the value of PI
PI = 3.14
# Getting input from user
R = float(input("Enter radius of the circle: "))
# Finding the area and perimeter of the circle
area = (PI*R*R)
perimeter = (2*PI*R)
# Printing the area and perimeter of the circle
print("The area of circle is", area)
print("The perimeter of circle is", perimeter)
4. Simple Interest Calculation
# Python program to find simple interest
p = float(input("Enter the principle amount : "))
r = float(input("Enter the rate of interest : "))
t = float(input("Enter the time in the years: "))
# calculating simple interest
2025-26/Flyers 1 /AI/Python (Programs) Page 1 of 5
si = (p*r*t)/100
# printing the values
print("Principle amount: ", p)
print("Interest rate : ", r)
print("Time in years : ", t)
print("Simple Interest : ", si)
5. Python program to check the given number is Even/Odd
# input the number
n1=int(input('Enter the value for n1: '))
# To check for Even/Odd
if n1%2 ==0:
print(n1, ' is an Even No')
else:
print(n1, ' is an Odd No')
6. Python program to check the given year is a leap year or not
# input the year
y=int(input('Enter the value of year: '))
# To check for non century year
if y%400==0 or y%4==0 and y%100!=0:
print('The given year is a leap year.')
else:
print('The given year is a non-leap year.')
7. Find largest of three number using nested if else
# input three integer numbers
a=int(input("Enter A: "))
b=int(input("Enter B: "))
c=int(input("Enter C: "))
# conditions to find largest
if a>b:
if a>c:
print("Greater = ",a)
else:
print("Greater = ",c)
else:
if b>c:
print("Greater = ",b)
else:
print("Greater = ",c)
8. Find Minimum of three number using nested if..elif and Logical Operators
# input three integer numbers
a=int(input("Enter A: "))
b=int(input("Enter B: "))
c=int(input("Enter C: "))
# conditions to find Minimum
if a<b and a<c:
print("Minimum = ",a)
elif b<a and b<c:
2025-26/Flyers 1 /AI/Python (Programs) Page 2 of 5
print("Minimum = ",b)
else:
print("Minimum = ",c)
9. Given two numbers and we have to design a calculator type application that will perform add,
subtract, multiply and divide
##operations using Python.
# menus
print("Calculator")
print("[Link]")
print("[Link]")
print("[Link]")
print("[Link]")
# input choice
ch=int(input("Enter Choice(1-4): "))
a=int(input("Enter A:"))
b=int(input("Enter B:"))
if ch==1:
print("Sum = ",a+b)
elif ch==2:
print("Difference = ",a-b)
elif ch==3:
print("Multiply = ",a*b)
elif ch==4:
print("Divide = ",a/b)
else:
print("Invalid Choice")
10. Print all the numbers between 1 to N.
n=int(input("Enter N: "))
for i in range(1,n+1):
print(i)
11. Print table of a number
n=int(input("Enter N: "))
for i in range(1,11):
print(n,"x",i,"=",i*n)
12. Find the sum of N number
n=int(input("Enter N: "))
s=0
for i in range(1,n+1):
s=s+i
print("Sum = ",s)
13. Check prime number
n=int(input("Enter N: "))
c=0
for i in range(1,n+1):
if n%i==0:
2025-26/Flyers 1 /AI/Python (Programs) Page 3 of 5
c=c+1
if c==2:
print(n,"is Prime")
else:
print(n,"is Not Prime")
14. Python while Loop
# program to display numbers from 1 to 5
# initialize the variable
i=1
n=5
# while loop from i = 1 to 5
while i <= n:
print(i)
i=i+1
15. Using break statement in Python while Loop
# to print number 1 to 5
i=1
while i <= 10:
print(i)
if i >= 5:
break
i=i+1
16. Python continue Statement with while Loop
# program to print odd numbers from 1 to 10
num = 0
while num < 10:
num += 1
if (num % 2) == 0:
continue
print(num)
17. To create a list in Python
#empty list
empty_list = []
#list of integers
age = [15,12,18]
#list with mixed data types
student_height_weight = ["Ansh", 5.7, 60]
18. To Access List Elements
languages = ["Python", "Swift", "C++"]
# access item at index 0
print(languages[0]) # Python
# access item at index 2
print(languages[2]) # C++
19. Negative Indexing in Python
languages = ["Python", "Swift", "C++"]
2025-26/Flyers 1 /AI/Python (Programs) Page 4 of 5
# access item at index 0
print(languages[-1]) # C++
# access item at index 2
print(languages[-3]) # Python
20. Add Elements to a List
numbers = [21, 34, 54, 12]
print("Before Append:", numbers)
# using append method
[Link](32)
print("After Append:", numbers)
21. Change List Items
languages = ['Python', 'Swift', 'C++']
# changing the third item to 'C'
languages[2] = 'C'
print(languages) # ['Python', 'Swift', 'C']
22. Remove an Item From a List
languages = ['Python', 'Swift', 'C++', 'C', 'Java', 'Rust', 'R']
# deleting the second item
del languages[1]
print(languages) # ['Python', 'C++', 'C', 'Java', 'Rust', 'R']
# deleting the last item
del languages[-1]
print(languages) # ['Python', 'C++', 'C', 'Java', 'Rust']
# delete the first two items
del languages[0 : 2] # ['C', 'Java', 'Rust']
print(languages)
2025-26/Flyers 1 /AI/Python (Programs) Page 5 of 5