Artificial Intelligence (417) Practical File
Submitted by: Student Name
Course Code: AI-417
Date of Submission: 29-08-2025
Program 1: Add the elements of the two lists
list1 = [1, 2, 3]
list2 = [4, 5, 6]
result = [x + y for x, y in zip(list1, list2)]
print(result)
Output:
[5, 7, 9]
Program 2: Calculate mean, median and mode using Numpy
import numpy as np
from scipy import stats
data = [1, 2, 2, 3, 4]
print("Mean:", [Link](data))
print("Median:", [Link](data))
print("Mode:", [Link](data).mode[0])
Output:
Mean: 2.4
Median: 2.0
Mode: 2
Program 3: Display line chart from (2,5) to (9,10)
import [Link] as plt
x = [2, 9]
y = [5, 10]
[Link](x, y)
[Link]()
Output:
A line chart from point (2,5) to (9,10).
Program 4: Display scatter chart
import [Link] as plt
x = [2, 9, 8, 5, 6]
y = [5, 10, 3, 7, 18]
[Link](x, y)
[Link]()
Output:
A scatter chart showing the given points.
Program 5: Read CSV file and display 10 rows
import pandas as pd
df = pd.read_csv("[Link]")
print([Link](10))
Output:
First 10 rows of the CSV file.
Program 6: Read CSV file and display its information
import pandas as pd
df = pd.read_csv("[Link]")
print([Link]())
Output:
Information about the CSV file.
Program 7: Read an image and display using Python
import cv2
img = [Link]("[Link]")
[Link]("Image", img)
[Link](0)
[Link]()
Output:
Image displayed in a window.
Program 8: Read an image and identify its shape
import cv2
img = [Link]("[Link]")
print("Image Shape:", [Link])
Output:
Image Shape: (height, width, channels)
Program 9: Find largest number in a list
numbers = [10, 25, 3, 89, 45]
print(max(numbers))
Output:
89
Program 10: Split even and odd elements into two lists
numbers = [1, 2, 3, 4, 5, 6]
even = [x for x in numbers if x % 2 == 0]
odd = [x for x in numbers if x % 2 != 0]
print("Even:", even)
print("Odd:", odd)
Output:
Even: [2, 4, 6]
Odd: [1, 3, 5]
Program 11: Find average of a list
numbers = [10, 20, 30, 40]
avg = sum(numbers) / len(numbers)
print(avg)
Output:
25.0
Program 12: Create dictionary from an object
class Student:
def __init__(self, name, age):
[Link] = name
[Link] = age
s = Student("John", 21)
print(s.__dict__)
Output:
{'name': 'John', 'age': 21}
Program 13: Check if a key exists in a dictionary
d = {'a': 1, 'b': 2}
print('a' in d)
print('c' in d)
Output:
True
False
Program 14: Add a key-value pair to the dictionary
d = {'a': 1, 'b': 2}
d['c'] = 3
print(d)
Output:
{'a': 1, 'b': 2, 'c': 3}
Program 15: Find the sum of all the items in a dictionary
d = {'a': 10, 'b': 20, 'c': 30}
print(sum([Link]()))
Output:
60
Program 16: Create a list of tuples (number, square of number)
numbers = [1, 2, 3, 4]
result = [(x, x**2) for x in numbers]
print(result)
Output:
[(1, 1), (2, 4), (3, 9), (4, 16)]
Program 17: Remove all tuples in a list outside a given range
tuples = [(1, 1), (2, 4), (3, 9), (4, 16)]
result = [t for t in tuples if 2 <= t[0] <= 3]
print(result)
Output:
[(2, 4), (3, 9)]