Std. Ix - 2025-26 - Record File - Python Programs and Outputs
Std. Ix - 2025-26 - Record File - Python Programs and Outputs
STD. IX (2025-26)
ARTIFICIAL INTELLIGENCE (417) – PRACTICAL RECORD FILE
LIST OF PYTHON PROGRAMS
NOTE:
**
1. All the programs to be written on the rule sided page and it’s related outputs to be written on the white
page with black ball point pen.
2. Index page should be maintained in the same order of programs.
3. Cover the computer record with brown cover.
PROGRAM Write a program in python a=30
01 that converts one data type b=40.0
to another data type. print(' The type of a is', type(a))
(IMPLICIT print(' The type of b is', type(b))
CONVERSION) c=a+b
print(" The value of c is: ", "and it's type
is", type(c))
OUTPUT:01
The type of a is <class 'int'>
The type of b is <class 'float'>
The value of c is: and it's type is <class 'float'>
PROGRAM Write a program in python a=144
02 that converts one data type b=144.0
to another data type.
c='69'
(EXPLICIT
CONVERSION) print('Variable a converted into string', str (a))
print('Variable a converted into float', float (a))
print('Variable b converted into integer', int (b))
print('Variable b converted into string', str (b))
print('Variable c converted into integer', int (c))
print('Variable c converted into float', float (c))
print('Variable c converted into list', list (c))
OUTPUT:02
Variable a converted into string 144
Variable a converted into float 144.0
Variable b converted into integer 144
Variable b converted into string 144.0
Variable c converted into integer 69
Variable c converted into float 69.0
Variable c converted into list ['6', '9']
PROGRAM Write a program in python to a1= input ("Enter the 1st Number:")
03 input two numbers and find
a1= eval(a1)
their sum and product.
a2= input ("Enter the 2nd Number:")
a2= eval(a2)
Total = a1 + a2
print("Sum of the numbers=", Total)
Product = a1*a2
print("Product of the numbers=", Product)
OUTPUT:03
Enter the 1st Number:20
Enter the 2nd Number:60
Page 1 of 10
Sum of the numbers= 80
Product of the numbers= 1200
PROGRAM Write a program in python to principal = eval(input("Enter the Principal amount:"))
04 calculate simple interest by rate = eval(input("Enter the annual interest rate:"))
inputting that value of time=2
Principal amount and rate simple_interest = (principal*rate*time) / 100
from user for a time period of amount = simple_interest + principal
2 years.
print ("Simple Interest is:", simple_interest)
print ("Amount Payable is:", amount)
OUTPUT:04
Enter the Principal amount:5000
Enter the annual interest rate:4.5
Simple Interest is: 450.0
Amount Payable is: 5450.0
PROGRAM WAP in python to check Age = int (input( "Enter age of a person:" ))
05 whether a person is eligible to if Age>=18:
vote or not. print ("The Person is eligible to case the vote.")
else:
print ("The Person is eligible to case the vote.")
OUTPUT:05
Enter age of a person:25
The Person is eligible to case the vote.
Enter age of a person:12
The Person is eligible to case the vote.
PROGRAM WAP to Input a number and num = float(input("Enter a number: "))
06 check if the number is if num > 0:
positive, negative or zero print("Positive number")
and display an appropriate elif num == 0:
message
(using if-elif-else) print("Zero") else:
print("Negative number")
OUTPUT:06
Enter a number: 4
Positive number
Enter a number: -3
Negative number
Enter a number: 0
Zero
PROGRAM WAP to Input a number and num = int(input("Enter a number: "))
07 check if the number is if num >= 0:
positive, negative or zero if num==0:
and display an appropriate print ("Zero")
message
(using nested if) else:
print ("positive Number")
else:
print ("negative Number")
OUTPUT:07
Enter a number: 5
positive Number
Enter a number: -2
negative Number
Enter a number: 0
Page 2 of 10
Zero
PROGRAM Write a program in python a=5
08 to show a finite loop. while a>0:
print(a)
a-=1
print ("end")
OUTPUT:08
This is loop iteration number: 1
Loop has finished.
This is loop iteration number: 2
Loop has finished.
This is loop iteration number: 3
Loop has finished.
This is loop iteration number: 4
Loop has finished.
This is loop iteration number: 5
Loop has finished.
PROGRAM Write a program in python a=1
09 to print the sum of first 10 sum=0
numbers. while (a<6):
sum = sum+a
a+=1
else:
print ("The Sum of First Ten integers is:", sum)
OUTPUT:09
The Sum of First Ten integers is: 15
PROGRAM Write a program in python i=2
10 to print the prime numbers while (i<50):
from 20 to 50. j=2
while (j<=(i/j)):
if not (i%j): break
j=j+1
if (j>i/j):
print (i)
i= i + 1
print ("End")
OUTPUT:10
2
3
5
7
11
13
17
19
23
29
31
Page 3 of 10
37
41
43
47
End
PROGRAM Write a program in python List1 = ["Hi","Hello","Bye"]
11 to use for loop by entering for x in List1:
the data using list. print (x)
OUTPUT:11
Hi
Hello
Bye
PROGRAM Write a program in python digits= [0, 1, 5]
12 to use for loop with else for i in digits:
statement. print(i)
else:
print ("No Items Left")
OUTPUT:12
0
1
5
No Items Left
PROGRAM Write a program in python a=2
13 to show the demonstration while True:
of break statement using print (a)
infinite loop. a+=2
if a>20:
break
OUTPUT:13
2
4
6
8
10
12
14
16
18
20
PROGRAM Write a program in python i=0
14 to show the demonstration while i<6:
of continue statement. i+=1
if i==3:
continue
print(i)
OUTPUT:14
1
2
Page 4 of 10
4
5
6
PROGRAM Write a program using while num = int(input("Enter a number to start the countdown: "))
15 loop asks the user for a while num >= 0:
number, and prints a print(num)
countdown from that
num= num - 1
number to zero.
OUTPUT:15
Enter a number to start the countdown: 5
5
4
3
2
1
0
PROGRAM Write a python script to num = int (input("Enter an Integer > 1000:"))
16 read an integer > 1000 and tnum= num
reverse the number. reverse=0
while tnum:
digit= tnum % 10
tnum = tnum / 10
reverse = reverse * 10 + digit
print ("Reverse of", num, "is", reverse)
OUTPUT:16
Enter an Integer > 1000:200
Reverse of 200 is 2e-323
Enter an Integer > 1000:50
Reverse of 50 is 5e-324
PROGRAM write a program in python to rows = 5
17 print the following output. for i in range(1, rows + 1):
1 print("1 " * i)
11
OUTPUT:17
111
1
1111
11111 11
111
1111
11111
PROGRAM Write a program in python sum = 0
18 to check whether a given n = int(input("Enter a Number: "))
number is armstrong or not n1 = n
while n > 0:
a = n % 10
sum += a ** 3
n = n // 10 # Use integer division
if sum == n1:
print("n is an Armstrong number")
else:
print("n is not an Armstrong number")
Page 5 of 10
OUTPUT:18
Enter a Number: 153
n is an Armstrong number
Page 7 of 10
cherry
date
list1 == list2: True
list1 == list3: False
list1 is list2: False
After append: [1, 2, 3, 4]
After extend: [1, 2, 3, 4, 5, 6]
After insert: [1, 2, 99, 3, 4, 5, 6]
After remove: [1, 2, 3, 4, 5, 6]
After pop: [1, 2, 3, 4, 5]
Popped item: 6
Sorted list: [1, 2, 3, 4, 5]
Reversed list: [5, 4, 3, 2, 1]
PROGRAM Write a program in python # Sample list
20 to perform the following my_list = [5, 3, 7, 3, 9, 1, 3, 7]
functions. print("Original List:", my_list)
i. count() # count()
ii. del()
iii. index() element_to_count = 3
iv. max() count_result = my_list.count(element_to_count)
v. min() print(f"Count of {element_to_count} in list:", count_result)
vi. clear() # del() - delete element at index 2
del_index = 2
print(f"Deleting element at index {del_index} which is
{my_list[del_index]}")
del my_list[del_index]
print("List after deletion:", my_list)
# index()
element_to_find = 7
if element_to_find in my_list:
index_result = my_list.index(element_to_find)
print(f"Index of first occurrence of {element_to_find}:",
index_result)
else:
print(f"{element_to_find} not found in list.")
# max()
if my_list:
max_value = max(my_list)
print("Maximum value in the list:", max_value)
else:
print("List is empty. Cannot find max.")
# min()
if my_list:
min_value = min(my_list)
print("Minimum value in the list:", min_value)
else:
print("List is empty. Cannot find min.")
# clear()
Page 8 of 10
print("Clearing the list...")
my_list.clear()
print("List after clear():", my_list)
OUTPUT:20
Original List: [5, 3, 7, 3, 9, 1, 3, 7]
Count of 3 in list: 3
Deleting element at index 2 which is 7
List after deletion: [5, 3, 3, 9, 1, 3, 7]
Index of first occurrence of 7: 6
Maximum value in the list: 9
Minimum value in the list: 1
Clearing the list...
List after clear(): []
*******
Page 9 of 10
Page 10 of 10