Mentora School
HomeASSEB AI HubUnit 4: Programming for AI
Class XIASSEB-527Unit 4: Programming for AI

Unit 4: Programming for AI

Master ASSEB Class XI AI Unit 4: Python fundamentals, Jupyter, Google Colab, Kaggle, NumPy, Pandas, Matplotlib, and textbook code errata.

Theory: 5 Marks
Practical: 10 Marks
12 min read
Subscription Gate Active
AHSEC / ASSEB Higher Secondary Syllabus

Unlock Unit 4: Programming for AI

Access verified code errata manual, 50 external viva questions, period lesson scripts, and practical examination rubrics.

256-Bit Encrypted Payment • Supports UPI, Cards & NetBanking
Prefer annual board pass?View All Passes & Billing
Official Textbook Exercises & Master Solutions

Class XI • Unit 4 Exercise Solutions

Human-crafted academic answers for all exercise questions (Pages 26–29) formulated to secure full marks in the ASSEB Board Examinations. Includes step-by-step calculations, diagrams, and examiner scoring tips.

Q1SECTION A: Core 1-Mark Objective Questions & Answers1 Mark

Which built-in function in Python outputs text to the console screen?

Q2SECTION A: Core 1-Mark Objective Questions & Answers1 Mark

What is the data type returned by type(3.14) in Python?

Q3SECTION A: Core 1-Mark Objective Questions & Answers1 Mark

Which sequence data structure in Python is MUTABLE?

Q4SECTION A: Core 1-Mark Objective Questions & Answers1 Mark

What is the primary Python library used for reading, cleaning, and manipulating tabular data frames?

Q5SECTION A: Core 1-Mark Objective Questions & Answers1 Mark

What does the floor division operator // compute in Python?

Q1SECTION B: Short Answer Questions (Model 2-Mark & 3-Mark Answers)2 Marks

What is the difference between a variable and a constant in Python?

A variable is a named location in memory whose value can be reassigned during program execution (e.g., score = 10; score = 20). A constant represents a fixed value that is not intended to change throughout execution (conventionally named in ALL_CAPS in Python, e.g., PI = 3.14159).

Q2SECTION B: Short Answer Questions (Model 2-Mark & 3-Mark Answers)2 Marks

Explain the purpose and importance of indentation in Python.

Unlike languages like C++ or Java that use curly brackets {} to delimit code blocks, Python uses whitespace indentation (conventionally 4 spaces) to define the structural scope of conditional blocks, loops, and function definitions. Inconsistent indentation causes an IndentationError.

Q3SECTION B: Short Answer Questions (Model 2-Mark & 3-Mark Answers)3 Marks

Differentiate between a for loop and a while loop with code examples.

for loop: Used when iterating over a known sequence or collection of elements.for x in range(3): print(x) (Prints 0, 1, 2)

while loop: Repeats indefinitely as long as a Boolean condition remains True.count = 0while count < 3: count += 1

Q4SECTION B: Short Answer Questions (Model 2-Mark & 3-Mark Answers)3 Marks

What are NumPy arrays and why are they preferred over standard Python lists in AI?

NumPy arrays (ndarray) store homogeneous data elements in contiguous memory blocks, enabling vectorized, low-level C-compiled arithmetic operations without Python loop overhead. They are orders of magnitude faster, consume significantly less memory, and support multi-dimensional matrix operations essential for neural networks.

Q1SECTION C: Long Answer Questions (Model 5-Mark Comprehensive Answers)5 Marks

Write a complete Python program using Pandas and Matplotlib to: (1) Create a DataFrame of 3 students with columns 'Name', 'Attendance', and 'Marks', (2) Calculate the average Marks, and (3) Plot a bar chart of Names versus Marks.

import pandas as pdimport matplotlib.pyplot as plt# 1. Create student datasetdata = { 'Name': ['Ananya', 'Bikash', 'Chayanika'], 'Attendance': [92, 85, 96], 'Marks': [78, 88, 92]}df = pd.DataFrame(data)print("--- Student DataFrame ---")print(df)# 2. Calculate average marksavgmarks = df['Marks'].mean()print(f"Average Marks: {avgmarks:.2f}")# 3. Plot Bar Chartplt.bar(df['Name'], df['Marks'], color='teal')plt.xlabel('Student Name')plt.ylabel('Marks Scored (out of 100)')plt.title('Student Academic Performance in AI')plt.ylim(0, 100)plt.show()

Q2SECTION C: Long Answer Questions (Model 5-Mark Comprehensive Answers)5 Marks

Explain Python file handling. Detail the modes ('r', 'w', 'a'), the purpose of the with context manager, and demonstrate how to read and write a JSON file.

Q1SECTION C: Long Answer Questions (Model 5-Mark Comprehensive Answers)5 Marks

File Modes: 'r' opens an existing file for reading; 'w' opens for writing (overwriting existing content); 'a' opens for appending new data to the end of the file.

Q2SECTION C: Long Answer Questions (Model 5-Mark Comprehensive Answers)5 Marks

The with Context Manager: Automatically guarantees that file descriptors are released and the file is safely closed when the indented block finishes, even if an unhandled runtime exception occurs.

Q3SECTION C: Long Answer Questions (Model 5-Mark Comprehensive Answers)5 Marks

JSON File Handling Example:

import json# Writing to JSONconfig = {'learningrate': 0.01, 'batchsize': 32, 'model': 'CNN'}with open('modelconfig.json', 'w') as f: json.dump(config, f, indent=4)# Reading from JSONwith open('modelconfig.json', 'r') as f: loadedconfig = json.load(f)print("Loaded Learning Rate:", loadedconfig['learning_rate'])