You are on page 1of 17

GRD PUBLIC SCHOOL

AVINASHI ROAD, COIMBATORE - 641014

CLASS: X

ARTIFICIAL INTELLIGENCE PRACTICAL FILE

Register No.

Certified to be the bonafide record work done by ___________________________________

during the year 2023-24.

Principal Teacher-in-Charge

Submitted for the Practical Examination held on _________________________________ at


GRD PUBLIC SCHOOL.

External: Internal:

Date: Date:
CONTENTS

Ex.No. Date Practical Teacher’s Sign.

1 Find the sum and average marks.


2
Swapping two variables.
Calculate the simple interest and compound
3
interest.
4
Find the greater number.
Check whether a number is positive, negative
5
or zero.
6
Find the first 5 multiples of 8.
7
Find a factorial of a number.
Print a whole list, add, delete and remove a
8
student name.
Create a list of 10 numbers and perform the
following few tasks:
 Print the length of the list
 Print the elements from second to fourth
using positive indexing.
 Print the elements from third to fifth
using negative indexing.
9  Sorting in ascending order.
10
Add the elements of two lists.
11
Calculate mean, median and mode.
12
Display line chart.
13
Display a scatter chart.
Read csv file saved in our system and display
14
its information.
Read an image, display and identify its
15 shape using Python.
1. Python program to find the sum and average marks of 5 subjects.

AIM:To write a Python program to find the average marks of 5 subjects.

SOURCE CODE:
print("Enter the marks obtained in 5 subjects")
mOne=int(input("Enter the marks in Math:"))
mTwo=int(input("Enter the marks in Science:"))
mThree=int(input("Enter the marks in Social studies:"))
mFour=int(input("Enter the marks in English:"))
mFive=int(input("Enter the marks in Tamil/Hindi:"))
sum=mOne+mTwo+mThree+mFour+mFive
avg=sum/5
print("Average Mark is",avg)

OUTPUT:
2. Python program swap two variables.

AIM:To write a Python program swap two variables.

SOURCE CODE:
P=int(input("Please enter the value for P:"))
Q=int(input("Please enter the value for Q:"))
temp=P
P=Q
Q=temp
print("The value of P after swapping:",P)
print("The value of Q after swapping:",Q)

OUTPUT:
3. Python program to calculate the simple interest and compound interest.

AIM:To write a Python program to calculate the simple interest and


compound interest.

SOURCE CODE:

principal = float(input('Enter amount: '))


time = float(input('Enter time: '))
rate = float(input('Enter rate: '))
simple_interest = (principal*time*rate)/100
compound_interest = principal * ((1+rate/100)**time - 1)
print(“Simple interest is:”, simple_interest)
print(“Compound interest is:”,compound_interest)

OUTPUT:
4. Python program to find the greater number.

AIM: To write a Python programto find the greater number out of the given
three numbers.

SOURCE CODE:
n1=int(input("Enter the first number:"))
n2=int(input("Enter the second number:"))
n3=int(input("Enter the third number:"))
if n1>n2 and n1>n3:
print(n1,"is greater")
elif n2>n1 and n2>n3:
print(n2,"is greater")
elif n3>n1 and n3>n2:
print(n3,"is greater")
else:
print("All are equal")

OUTPUT:
5. Python program to check whether a number is positive, negative or zero.

AIM:To write a Python program to check whether a number is positive,


negative or zero.

SOURCE CODE:
a=int(input("Enter the number:"))
if a>0:
print("The number given is positive")
elif a<0:
print("The number given is negative")
else:
print("The number is zero")

OUTPUT:
6. Python program to find the first 5 multiples of 8.

AIM:To write a Python program to find the first 5 multiples of 8.

SOURCE CODE:
num=int(input(“Enter the number:”))
for i in range(1, 6):
print(num, 'x', i, '=', num*i)

OUTPUT:
7. Python program to find a factorial of a number.

AIM: To write a Python program to find a factorial of a number.

SOURCE CODE:
n=int(input("Enter the number:"))
factorial = 1
if n>=1:
for i in range(1,n+1):
factorial=factorial*i
print("Factorial of the given number is:",factorial)

OUTPUT:
8. Python program to print a whole list, add, delete and remove a student
[

name.

AIM:To Write a Python program to print a whole list, add, delete and remove
a student name

SOURCE CODE:
mylist=["Anu","Banu","Hema"]
print(mylist)
mylist.append("Balu")
print("List after after append:")
print(mylist)
mylist =["Anu","Banu","Hema","Balu"]
mylist.remove("Anu")
print("List after removing an element:")
print(mylist)
mylist=["Anu”,”Banu","Hema"]
mylist.pop(0)
print(mylist)

OUTPUT:
9. Create a list of 10 numbers and perform the following few tasks:

AIM: To write a Python program to perform the following tasks:


 Print the length of the list
 Print the elements from second to fourth using positive indexing.
 Print the elements from third to fifth using negative indexing.
 Sorting in ascending order.

SOURCE CODE:
mylist=[23,45,34,46,7,3,78,9,34,15]
print(len(mylist))
mylist=[23,45,34,46,7,3,78,9,34,15]
print(mylist[2:5])
mylist=[23,45,34,46,7,3,78,9,34,15]
print(mylist[-5:-2])
mylist=[23,45,34,46,7,3,78,9,34,15]
mylist.sort()
print(mylist)

OUTPUT:
10. Python program to add the elements of two lists.

AIM:To write a Python program to add the elements of two lists.

SOURCE CODE:
List1=[1,2,3]
List2=[2,4,6]
List3=[]
print("List1 value",List1)
print("List2 value",List2)
for n in range(0,len(List1)):
List3.append(List1[n]+List2[n])
print("Sum of two lists",List3)

OUTPUT:
11. Python program to calculate mean, median and mode.

AIM:To write a Python program to calculate mean, median and mode.

SOURCE CODE:
import numpy
from scipy import stats
speed = [99,86,87,88,111,86,103,87,94,78,77,85,86]
x = numpy.mean(speed)
print("MEAN",x)
y = numpy.median(speed)
print("MEDIAN",y)
z = stats.mode(speed, keepdims=”true”)
print("MODE",z)

OUTPUT:
12. Python programto display line chart.

AIM:To write a Python programto display line chart.

SOURCE CODE:

importmatplotlib.pyplot as plt
Grade=[1,2,3,4,5]
mark1=[80,90,98,78,86]
mark2=[54,65,76,87,98]
plt.title('AVERAGE MARK DISTRIBUTION CLASSWISE')
plt.plot(Grade,mark1,linewidth=3,color='cyan',label='MARKS1',linestyle='da
shed')
plt.plot(Grade,mark2,linewidth=3,color='r',label='MARKS2')
plt.xlabel('Class')
plt.ylabel('Average marks')
plt.legend(loc='lower right')
plt.show()

OUTPUT:
13. Python program to display a scatter chart.

AIM:To write a Python programto display a scatter chart.

SOURCE CODE:
import matplotlib.pyplot as plt
Sales=[510,350,475,580,600]
Month=['January','February','March','April','May']
plt.title('The Monthly Sales Report')
plt.scatter(Month,Sales,linewidth=3,color='blue',linestyle='dashed',label='Re
port')
plt.plot(Month,Sales,linewidth=3,color='blue',linestyle='dashed',label='Repo
rt')
plt.xlabel('Month')
plt.ylabel('Sales')
plt.legend(loc='lower right')
plt.show()

OUTPUT:
14. Python program to read csv file saved in our system and display its
information.

AIM:ToWrite a Python program to read csv file saved in our system and
display its information.

SOURCE CODE:
import pandas as pd
dataset = pd.read_csv(r'C:\Users\Administrator\Desktop\trial.csv')
print(dataset)

OUTPUT:
15. Python program to read an image, display and identify its shape using
Python.

AIM: ToWrite a Python program toread animage, display and identify its
shape using Python.

SOURCE CODE:
importmatplotlib.image as mpimg
importmatplotlib.pyplot as plt
img = mpimg.imread(r'C:\Users\Administrator\Pictures\im1.jpg')
plt.imshow(img)
print(img.shape)

OUTPUT:

You might also like