SESSION 2025-2026
ARTIFICIAL INTELLIGENCE (SUB. CODE 417) – PRCATICALS
CLASS – X
PART-C: PRACTICAL WORK FOR TERM 1
1 Write a Python program to check if a person is eligible to vote or not.
Program:
# Get the user's age
age = int(input("Enter your age: "))
# Check eligibility
if age >= 18:
print("You are eligible to vote.")
else:
print("You are not eligible to vote.")
Output:
2 Write a Python program to check the grade of a student.
Program:
score = float(input("Enter the student's score (0-100): "))
# Determine the grade
if score >= 90:
grade = 'A'
elif score >= 80:
grade = 'B'
elif score >= 70:
grade = 'C'
elif score >= 60:
grade = 'D'
else:
grade = 'F'
# Print the grade
print("The student's grade is:", grade)
Output:
3 Write a Python program to Input a number and check if the number is
positive, negative or zero and display an appropriate message.
Program:
# Get the number from the user
number = float(input("Enter a number: "))
# Check if the number is positive, negative, or zero
if number > 0:
print("The number is positive.")
elif number < 0:
print("The number is negative.")
else:
print("The number is zero.")
Output:
4 Write a python program to Find the Greatest Among Three Numbers.
Program:
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
num3 = float(input("Enter third number: "))
# Compare the numbers
if num1 >= num2 and num1 >= num3:
greatest = num1
elif num2 >= num1 and num2 >= num3:
greatest = num2
else:
greatest = num3
# Output the greatest number
print("The greatest number is:", greatest)
Output:
5 Write a python program to plot a bar graph using the data given below:
Categories: Category A, Category B, Category C, Category D
Values: 10, 15, 7, 12
Program:
import matplotlib.pyplot as plt
# Sample data
categories = ['Category A', 'Category B', 'Category C', 'Category D']
values = [10, 15, 7, 12]
# Create a bar graph
plt.bar(categories, values, color='skyblue')
# Adding title and labels
plt.title('Bar Graph - Categories Vs Values')
plt.xlabel('Categories')
plt.ylabel('Values')
# Show the plot
plt.show()
Output:
6 Write a python program to plot a line graph using the data given below:
Exams: Exam 1, Exam 2, Exam 3, Exam 4, Exam 5
Marks: 85, 90, 78, 92, 88
Program:
import matplotlib.pyplot as plt
# Sample data for student marks in different exams
exams = ['PT1', 'Term 1', 'PT2', 'Model', 'Board']
marks = [85, 90, 78, 92, 88]
# Create a line graph for student marks
plt.plot(exams, marks, color='green')
# Adding title and labels
plt.title('Student Marks in Different Exams')
plt.xlabel('Exams')
plt.ylabel('Marks')
# Display the plot
plt.show()
Output:
7 Write a python program to Plot a line chart using the given temperature
data.
Program:
import matplotlib.pyplot as plt
# Monthly temperature data
months = ['January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December']
temperatures = [5, 7, 12, 18, 23, 28, 30, 29, 24, 18, 10, 6]
# Plotting the line chart
plt.plot(months, temperatures, marker='o', color='blue', linestyle='--')
# Adding title and labels
plt.title('Monthly Temperature Readings')
plt.xlabel('Month')
plt.ylabel('Temperature (°C)')
# Show the plot
plt.show()
Output:
8 Write a python program to Plot a bar graph using the given data.
Program:
import matplotlib.pyplot as plt
# Product sales data
products = ['Product A', 'Product B', 'Product C', 'Product D', 'Product E']
sales = [150, 300, 200, 100, 250]
# Plotting the bar graph
plt.bar(products, sales, color='purple')
# Adding title and labels
plt.title('Sales Data for Different Products')
plt.xlabel('Product')
plt.ylabel('Sales (units)')
# Show the plot
plt.show()
Output:
Python Programs
Write a program to add the elements of the two lists.
list1 = [10, 20, 30, 40]
list2 = [1, 2, 3, 4]
# Add the two lists element-wise
result = []
# Make sure both lists are of the same length
if len(list1) == len(list2):
for i in range(len(list1)):
result.append(list1[i] + list2[i])
print("Sum of elements:", result)
else:
print("Lists are of different lengths!")
Write a program to display line chart from (2,5) to (9,10).
import matplotlib.pyplot as plt
# Define the x and y coordinates
x = [2, 9]
y = [5, 10]
# Create the line chart
plt.plot(x, y, marker='o')
# Add labels and title
plt.title("Line Chart from (2,5) to (9,10)")
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
# Display the graph
plt.grid(True)
plt.show()
Write a program to display a scatter chart for the following points (2,5), (9,10),(8,3),(5,7),(6,18).
import matplotlib.pyplot as plt
# Define the x and y coordinates for the scatter plot
x = [2, 9, 8, 5, 6]
y = [5, 10, 3, 7, 18]
# Create the scatter plot
plt.scatter(x, y)
# Add labels and title
plt.title("Scatter Chart of Given Points")
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
# Display the graph
plt.grid(True)
plt.show()
Read the csv file saved in your system and display 10 rows.
import pandas as pd
# Replace the path below with the actual path to your CSV file
file_path = 'your_file_name.csv'
# Read the CSV file
data = pd.read_csv(file_path)
# Display the first 10 rows
print(data.head(10))
print("Information about the CSV file:")
print(data.info())
Read csv file saved in your system and display its information
import pandas as pd
# Replace with the actual path to your CSV file
file_path = 'your_file_name.csv'
# Read the CSV file
data = pd.read_csv(file_path)
# Display information about the DataFrame
print("Information about the CSV file:")
print(data.info())
# Creating a list of children selected for the science quiz
children = ["Arjun", "Sonakshi", "Vikram", "Sandhya", "Sonal", "Isha", "Kartik"]
print("Original List:", children) # Print the whole list
children.remove("Vikram") # Delete the name “Vikram” from the list
children.append("Jay") # Add the name “Jay” at the end
# Remove the item which is at the second position (index 1)
children.pop(1)
# Print the updated list
print("Updated List:", children)
Python program to calculate mean, median and mode using
Numpy.
import numpy as np
import statistics as st
data = [10, 20, 20, 30, 40, 40, 40, 50] # Sample data (you can also take input from the user)
mean = np.mean(data) # Calculate mean
median = np.median(data) # Calculate median
mode = st.mode(data) # Calculate mode
# Print results
print("Data:", data)
print("Mean:", mean)
print("Median:", median)
print("Mode:", mode)