0% found this document useful (0 votes)
17 views6 pages

Class 10 Python Practical Programs

Uploaded by

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

Class 10 Python Practical Programs

Uploaded by

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

PON VIDYASHRAM SENIOR SECONDARY SCHOOL –KOLAPAKKAM

ACADEMIC YEAR- 2025-26


CLASS 10 ARTIFICIAL INTELLIGENCE (417) PRACTICAL PROGRAM LIST
Activity 1: Write a Python program to print personal information like Name, Father’s Name, Class,
School Name.
AIM: To Write a Python program to print personal information like Name, Father’s Name, Class,
School Name.
Code:
print("My Name is:","Rajesh Kumar")
print("My Father Name is:","Rakesh Kumar")
print("My class is 10-A")
print("My School is","PON VIDYASHRAM SENIOR SECONDARY SCHOOL”)
o/p:
My Name is: Rajesh Kumar
My Father Name is: Rakesh Kumar
My class is 10-A
My School is PON VIDYASHRAM SENIOR SECONDARY SCHOOL
Result: Thus, the python program to print personal information like Name, Father’s Name, Class, School
Name. Executed successfully.

Activity2: Write a Python code to calculate Simple Interest if the principle_amount = 2000 rate_of_interest = 8 time = 10
Aim: To Write a Python code to calculate Simple Interest if the principle_amount = 2000 rate_of_interest = 8 time = 10
Code:
P=2000
T=10
R=8
SI=(P*T*R)/100
# calculates simple interest
print "Simple Interest is",SI)
o/p:
Simple Interest is 1600.0
Result:Thus, the Python code to calculate Simple Interest if the principle_amount = 2000
rate_of_interest = 8 time = 10. executed successfully
Activity 3: Write a Python code to calculate Area of a triangle with Base and Height
Code:
B=int(input("Enter Base of a rectangle")) # reading base value of the rectangle
H=int(input("Enter Height of a rectangle")) # reading height of the rectangle
print("Area of a rectangle is",0.5*B*H)
# displays area of the rectangle
o/p:
Enter Base of a rectangle5
Enter Height of a rectangle4
Area of a rectangle is 10.0
Activity 4: Write a Python code to check whether a person is eligible to vote or not.
Code:
Age=int(input("Enter person’s age"))

1
if Age>=18: # checking the condition
print("Person is Eligible to vote")
else:
print("Person is not Eligible to vote")
o/p:
Enter person’s age 21
Person is Eligible to vote

Activity 5: Write a Python code to print sum of first 10 natural numbers.


Code:
S=0
for i in range(1,11):
S=S+i
print("Sum of first 10 natural numbers is",S)
o/p:
Sum of first 10 natural numbers is 55
Activity 6: Write a Python code to assign the Grade based on the given percentage:
Code:
per=float(input("Enter students percentage"))
if per>=90: #checking the condition
grade="A" # assigning grade
elif per>=70 :
grade="B"
elif per>=50:
grade="C"
elif per>=33:
grade="D"
else:
grade="E"
print("Perntage is",per)
print("Grade is",grade)
o/p: Enter students percentage89
Perntage is 89.0
Grade is B
Activity 7: Write a program to create a list and display list elements.
Code:
l=[]
n=int(input("Enter length of the list"))
for i in range(n):
a=eval(input("Enter list element"))
[Link](a)
print("Created list is",l)
o/p:
Enter length of the list5
Enter list element10
Enter list element20.5

2
Enter list element45
Enter list element78
Enter list element23
Created list is [10, 20.5, 45, 78, 23]
Activity 8: Write a program to add the elements of the two lists.
Code:
l1=[20,30,40]
l2=[30,50,10]
l3=l1+l2
print("Addition of",l1,"and",l2,"is",l3)
o/p:
Addition of [20, 30, 40] and [30, 50, 10] is [20, 30, 40, 30, 50, 10]
Activity 9: Write a program to calculate mean, median and mode using Numpy
Code:
import numpy as np
import statistics as st
l=[30,20,50,60,20]
l1=[Link](l)
print("Mean of",l1,"is",[Link](l1))
print("Median of",l1,"is",[Link](l1))
print("Mode of",l1,"is",[Link](l1))
o/p:
Mean of [30 20 50 60 20] is 36
Median of [30 20 50 60 20] is 30
Mode of [30 20 50 60 20] is 20
Activity 10: Write a program to display line chart from (2,5) to (9,10).
Code:
import [Link] as plt

x=(2,9)
y=(5,10)
[Link](x,y)
[Link]("Line chart")
[Link]()
O/P:

3
Activity 11: Write a program to display a scatter chart for the following points (2,5),
(9,10),(8,3),(5,7),(6,18).
Code:
import [Link] as plt
x=[2,9,8,5,6]
y=[5,10,3,7,18]
[Link](x,y)
[Link]("Line chart")
[Link]()
o/p:

Activity 12: Write a program to display bar chart for the following data with appropriate titles:
Subjects=[“Eng”,”Sci”,”Soc”,”Maths”,”AI”]
Marks=[89,87,78,90,99]
Code:
import [Link] as plt
Sub=["Eng","Sci","Soc","Maths","AI"]
Marks=[89,87,78,90,99]
[Link](Sub,Marks)
[Link]("Term-1 Performance")
[Link]("Subjects")
[Link]("Marks")

4
[Link]()

O/P:

Activity 13: Write a program to display histogram for the following data with appropriate titles:
stu=[5,14,17,23,34,50,20,34,24,56,45,34,23,34,32,9,8,22,24,34,55,66,23,23 ]
Code:
import [Link] as plt
stu=[5,14,17,23,34,50,20,34,24,56,45,34,23,34,32,9,8,22,24,34,55,66,23,23]
[Link](stu,bins=[0,10,20,30,40,50,60,70])
[Link]("Marks")
[Link]("[Link] Students")
[Link]("Marks Obtained by the Students")
[Link]()
o/p:

Activity 14: Write a program to display Pie-chart for the following data with appropriate
titles:
Code:
import [Link] as plt
x=["Food","Rent","Shopping","Education","others"]

5
values=[20,30,25,35,50]
[Link](values,labels=x)
[Link]("Expenditure")
[Link]()

O/P:

Activity 15: Read CSV file saved in your system and display 5 rows
Code:
import pandas as pd
df=pd.read_csv(r"C:\Users\ADMIN\Desktop\[Link]",nrows=10)
print(df)
o/p:
RNO NAME MARKS
0 1 HARI 67
1 2 RAMESH 89
2 3 SOMESH 56
3 4 RAJESH 78
4 5 BHIMESH 45

Activity 16: Write a program to read an image and display using Python
Code:
import cv2
img=[Link]("[Link]")
[Link]('Image',img)
[Link](0)

o/p:

Common questions

Powered by AI

The program demonstrates list concatenation by using the '+' operator to combine the elements of two lists, l1 and l2. This operation merges both lists into a new list, l3, without modifying the original lists. It effectively demonstrates a fundamental list operation in Python .

The program uses conditional 'if-elif' statements to assign grades based on the input percentage. It categorizes percentages into grades 'A' through 'E' by checking sequential thresholds (90, 70, 50, 33). This systematic approach automates grading, ensuring consistency in evaluation .

The activity uses the 'pandas' library to read from a CSV file. The function 'read_csv' is employed, with the parameter 'nrows' limiting the number of rows displayed. This selective display is significant for handling large datasets efficiently, allowing focus on specific data portions without loading entire files into memory .

The use of OpenCV in Python for reading and displaying images enables various applications such as real-time image processing, computer vision tasks, and data analysis that involve visual information. The ability to manipulate and analyze images can be extended to projects in facial recognition, robotics, and automated surveillance .

The program checks the eligibility to vote using a conditional statement 'if'. It takes the age input and compares it to 18. If the age is 18 or more, it prints that the person is eligible to vote; otherwise, it states that the person is not eligible .

The activity demonstrates basic I/O operations in Python, including the use of the 'print' function to display text output. It illustrates string handling, as it concatenates and formats strings to display personal information such as name and school name .

The program uses the 'numpy' and 'statistics' libraries to compute statistical measures on a list of numbers. 'mean' calculates the average, 'median' finds the middle value, and 'mode' identifies the most frequently occurring number. These functions abstract complex operations into simple method calls .

Creating a list from user input involves dynamically using input() to gather elements and append them to a list. The challenge lies in handling different data types and ensuring valid input. Benefits include flexibility and interactivity, as it allows customization of list content by user preferences .

The document shows different types of charts: a line chart, scatter chart, bar chart, histogram, and pie chart, all generated using the 'matplotlib.pyplot' library. Each chart type visually represents data uniquely, such as the distribution of marks using a histogram or pie chart to show expenditures .

The program calculates simple interest by taking three variables: principle_amount, rate_of_interest, and time, and applying the formula SI = (P * T * R) / 100. This represents the arithmetic operation of multiplying and dividing to find interest based on percentage terms .

You might also like