Circle of Learning Logo CIRCLE OF LEARNING Excellence in Education
CBSE Class 9 · Artificial Intelligence Chapter 4 Session 2026-27

Python for AI: Core Syntax, Data Structures & Logic Formulas & Cheat Sheet

Complete chapter-wise reference, step-by-step formula explanations, structured table, and board exam trap warnings.

Core Concepts & Theoretical Foundations

  • Variables & Data Types: int, float, str, bool, list, tuple, dict.
  • Operators: Arithmetic (+, -, *, /, //, %, **), Relational (==, !=, >, <, >=, <=), Logical (and, or, not).
  • Control Flow: if-elif-else statements; indentation rules (4 spaces).
  • Loops: for loop (range function), while loop (condition-controlled).
  • Lists: Ordered, mutable collections; indexing, slicing, methods (.append(), .pop(), .sort(), .len()).

Chapter Formulas & Equations (2 entries)

# Topic / Formula Name Mathematical Form & Equation Conditions, Meaning & Board Tips
1 List Slicing Syntax Matrix
Sublist=L[i:j:k],i≤index<j\text{Sublist} = L[i : j : k], \quad i \le \text{index} < j

Negative indexing counts from the end (-1 is the last element, -2 is second to last).

2 Range Function Equation
range(a,b,s)={a+k⋅s∣0≤k<b−as}\text{range}(a, b, s) = \{ a + k \cdot s \mid 0 \le k < \frac{b-a}{s} \}

range(1, 10, 2) produces [1, 3, 5, 7, 9].

CBSE Board Exam Tips & Frequent Pitfalls

  • Python is case-sensitive; 'True' and 'False' must always have an uppercase first letter.
  • Indentation errors produce syntax errors in Python; ensure consistent spacing.

Step-by-Step Worked Board Exam Examples

Example 1: Write a Python program to calculate the average of numbers in a list: scores = [85, 90, 78, 92, 88].

Step 1: Compute sum using sum(scores).

Step 2: Get total count using len(scores).

Step 3: Divide sum by length to obtain average.

Step 4: Output the result.

Ans: scores = [85, 90, 78, 92, 88]\naverage = sum(scores) / len(scores)\nprint('Average score:', average)\n# Output: Average score: 86.6

Common Mistakes to Avoid in Exam

  • Using single '=' for comparison instead of '==' (e.g., writing 'if x = 5:' causes a SyntaxError).
  • Forgetting that range(0, 5) stops at 4, not 5.

Target Practice Questions

Q1. What is the output of the following Python expression: [1, 2, 3] * 2?

Correct Answer: [1, 2, 3, 1, 2, 3] (The multiplication operator replicates the list elements; it does not perform arithmetic multiplication on values).

Frequently Asked Questions

Q. Which Python libraries are essential for Class 9 and 10 AI?

NumPy (numerical arrays), Pandas (dataframes), Matplotlib (charts), and OpenCV (computer vision).

← View All 4 Chapters in Class 9 Artificial Intelligence Formula Book