AI Logic School

Empowering Students with AI & Computational Thinking

CBSE Class XII AI Lab Manual 2026-27 | All Programs with Code & Output

CBSE Class XII AI Lab Manual 2026-27 | All Programs with Code & Output
📘 AI Logic School

CBSE Class XII AI Lab Manual
2026-27

Complete Python programs with code & output for your CBSE/KVS board exam practical file. All units covered as per the latest syllabus.

5
Units
20+
Programs
100%
CBSE Aligned
Free
Download
ℹ️

Academic Year 2026-27 | Class XII | Subject: Artificial Intelligence (Code 843)
This lab manual is prepared as per the latest CBSE syllabus for Class 12 AI. Each program includes aim, Python code, and expected output — ready to copy into your practical file.

Class 12 AI Lab Manual Python Programs CBSE 2026-27 KVS Syllabus Practical File Board Exam Free Download

📚 Syllabus Units Covered

Unit 1
Introduction to AI
AI concepts, applications, domains, and history of AI development.
3 Programs
Unit 2
Data Science & Pandas
NumPy, Pandas DataFrames, data cleaning, analysis and visualization.
5 Programs
Unit 3
Machine Learning
Supervised, unsupervised learning, regression, classification using sklearn.
5 Programs
Unit 4
Computer Vision
Image processing, face detection, OpenCV basics and applications.
4 Programs
Unit 5
Natural Language Processing
Text processing, tokenization, sentiment analysis, NLP with Python.
4 Programs

🛠️ How to Use This Manual

1
Read the Aim — Understand what each program does before writing it.
2
Copy the Code — Use the copy button to copy code into your Python IDE (IDLE or VS Code).
3
Run & Verify — Run the program and match your output with the expected output given.
4
Write in Practical File — Note down Aim, Code, and Output neatly in your practical file.
5
Download PDF — Download the complete manual PDF using the button below for offline use.

💻 Python Programs with Code & Output

📌 Tip: All programs are written in Python 3. Make sure you have the required libraries installed using pip install numpy pandas matplotlib scikit-learn before running.
Prog 01
Print "Hello, Artificial Intelligence!"
Unit 1
🎯 Aim
To write a Python program to print a welcome message related to Artificial Intelligence.
🟢 Python Code
# Program 1: Hello AI print("Hello, Artificial Intelligence!") print("Welcome to CBSE Class 12 AI Lab") print("AI is transforming the world!") name = input("Enter your name: ") print(f"Hello {name}! Let's learn AI together.")
🖥️ Expected Output
Hello, Artificial Intelligence! Welcome to CBSE Class 12 AI Lab AI is transforming the world! Enter your name: Rahul Hello Rahul! Let's learn AI together.
Prog 02
NumPy Array Operations
Unit 2
🎯 Aim
To demonstrate basic NumPy array creation and arithmetic operations used in data science.
🟢 Python Code
import numpy as np # Create arrays a = np.array([10, 20, 30, 40, 50]) b = np.array([1, 2, 3, 4, 5]) print("Array A:", a) print("Array B:", b) print("Sum:", a + b) print("Difference:", a - b) print("Product:", a * b) print("Mean of A:", np.mean(a)) print("Max of A:", np.max(a)) print("Shape of A:", a.shape)
🖥️ Expected Output
Array A: [10 20 30 40 50] Array B: [1 2 3 4 5] Sum: [11 22 33 44 55] Difference: [ 9 18 27 36 45] Product: [ 10 40 90 160 250] Mean of A: 30.0 Max of A: 50 Shape of A: (5,)
Prog 03
Pandas DataFrame — Create & Analyse
Unit 2
🎯 Aim
To create a Pandas DataFrame of student records and perform basic data analysis operations.
🟢 Python Code
import pandas as pd # Create DataFrame data = { 'Name': ['Aarav', 'Priya', 'Rohan', 'Meena', 'Karan'], 'Marks': [85, 92, 78, 96, 88], 'Grade': ['A', 'A+', 'B+', 'A+', 'A'] } df = pd.DataFrame(data) print("Student Records:") print(df) print("\nBasic Statistics:") print(df['Marks'].describe()) print("\nAverage Marks:", df['Marks'].mean()) print("Highest Marks:", df['Marks'].max()) print("Student with highest marks:") print(df[df['Marks'] == df['Marks'].max()])
🖥️ Expected Output
Student Records: Name Marks Grade 0 Aarav 85 A 1 Priya 92 A+ 2 Rohan 78 B+ 3 Meena 96 A+ 4 Karan 88 A Basic Statistics: count 5.000000 mean 87.800000 std 6.760000 min 78.000000 max 96.000000 Average Marks: 87.8 Highest Marks: 96 Student with highest marks: Name Marks Grade 3 Meena 96 A+
Prog 04
Linear Regression using Scikit-learn
Unit 3
🎯 Aim
To implement a simple Linear Regression model to predict values using scikit-learn library.
🟢 Python Code
import numpy as np from sklearn.linear_model import LinearRegression import matplotlib.pyplot as plt # Training data (Hours studied vs Marks) X = np.array([1,2,3,4,5,6,7,8]).reshape(-1,1) y = np.array([35,45,55,65,70,78,85,92]) # Create and train model model = LinearRegression() model.fit(X, y) # Predict hours = np.array([[9]]) predicted = model.predict(hours) print("Model trained successfully!") print(f"Slope (m): {model.coef_[0]:.2f}") print(f"Intercept (b): {model.intercept_:.2f}") print(f"Predicted marks for 9 hours study: {predicted[0]:.1f}") # Plot plt.scatter(X, y, color='blue', label='Actual') plt.plot(X, model.predict(X), color='red', label='Regression Line') plt.xlabel('Hours Studied') plt.ylabel('Marks') plt.title('Linear Regression: Hours vs Marks') plt.legend() plt.show()
🖥️ Expected Output
Model trained successfully! Slope (m): 7.98 Intercept (b): 26.07 Predicted marks for 9 hours study: 97.9 [A graph window opens showing scatter plot with regression line]
Prog 05
K-Nearest Neighbour (KNN) Classifier
Unit 3
🎯 Aim
To implement KNN classification algorithm using the Iris dataset from scikit-learn.
🟢 Python Code
from sklearn.datasets import load_iris from sklearn.model_selection import train_test_split from sklearn.neighbors import KNeighborsClassifier from sklearn.metrics import accuracy_score # Load dataset iris = load_iris() X, y = iris.data, iris.target # Split data X_train, X_test, y_train, y_test = train_test_split( X, y, test_size=0.3, random_state=42) # Train KNN model knn = KNeighborsClassifier(n_neighbors=3) knn.fit(X_train, y_train) # Predict and evaluate y_pred = knn.predict(X_test) accuracy = accuracy_score(y_test, y_pred) print("KNN Classification on Iris Dataset") print(f"Training samples: {len(X_train)}") print(f"Testing samples: {len(X_test)}") print(f"Model Accuracy: {accuracy * 100:.2f}%") print("\nClass Names:", iris.target_names)
🖥️ Expected Output
KNN Classification on Iris Dataset Training samples: 105 Testing samples: 45 Model Accuracy: 97.78% Class Names: ['setosa' 'versicolor' 'virginica']

📥 Download Complete Lab Manual PDF

Get all 20+ programs with code, output, aim, and viva questions in one printable PDF. Perfect for your CBSE practical file submission.

⬇️ Download Full PDF — Free
📌 Note: This page shows 5 sample programs. The complete lab manual includes 20+ programs covering all 5 units including Computer Vision (OpenCV) and NLP programs. Download the PDF above for the full collection.

❓ Important Viva Questions

  1. What is Artificial Intelligence? Name its main domains.
  2. What is the difference between supervised and unsupervised learning?
  3. What is a DataFrame in Pandas? How is it different from a list?
  4. What does the train_test_split() function do?
  5. What is accuracy score in machine learning?
  6. What is Linear Regression? When is it used?
  7. What is KNN algorithm? What does 'K' represent?
  8. What is NumPy? Why is it used in data science?
  9. What is the difference between AI, ML, and Deep Learning?
  10. What is the Iris dataset? Why is it commonly used for practice?

🔗 Related Resources on AI Logic School

📗 Handbooks
CT & AI Teacher Handbooks
Class 3 to 12 teacher guides for Computational Thinking and AI subject.
📘 Class 10
Class 10 AI Notes
Complete notes and programs for CBSE Class 10 Artificial Intelligence.
📙 Class 11
Class 11 AI Lab Manual
Python programs and practical file content for Class 11 AI subject.

Comments

Chat on WhatsApp