FREE Live Master Session: Code Your AI Companion for Kids

    Register for Free →
    Subject 843 • Unit 3 • 5 Marks Theory (10h Theory + 20h Practical)

    Unit 3: Python ProgrammingLevel 1 Fundamentals to Level 2 NumPy, Pandas & Scikit-Learn

    The definitive CBSE Class 11 guide for Unit 3. Master Python tokens, dynamic typing, control flow, CSV file manipulation, NumPy ndarrays, Pandas DataFrames (.loc, .iloc, missing values), Scikit-Learn ML pipelines (Iris dataset & KNN), and 15 handbook MCQs.

    Practice 15 Handbook MCQs
    Level 1: Language Basics

    1. Python Tokens, Data Types & Dynamic Typing

    Python is a high-level, interpreted, general-purpose programming language created by Guido van Rossum and released in 1991. The smallest individual units of a Python program are called Tokens, categorized into 5 types:

    1. Keywords

    Reserved words with special meaning (e.g., False, None, True, def, if, elif, for, while, import, break).

    2. Identifiers

    User-defined names for variables, functions, and classes. Cannot start with a digit or contain special characters except underscore (_).

    3. Literals

    Raw fixed data values: String ("Ria"), Numeric (10, 5.5), Boolean (True/False), and Special (None).

    4. Operators

    Symbols triggering computations: Arithmetic (+,-,*,/,%), Relational (==,!=,<,>), Logical (and,or,not), Identity (is), and Membership (in).

    5. Punctuators

    Organizing delimiters: : , ( ) [ ] { } ; . " '

    Dynamic Typing

    Variables can hold different types during execution without explicit redeclaration. Type casting is done via int(), float(), str().

    Control Flow & Files

    2. Control Statements & CSV File Processing

    Control flow statements govern the execution path of programs through Selection (if-else, if-elif-else) and Iteration (for loop over sequences/ranges and while loop).

    # CSV Reading and Writing Example from CBSE Handbook
    import csv
    # Writing to a CSV file
    with open("student.csv", "w", newline="") as f:
    wr = csv.writer(f)
    wr.writerow(["RollNo", "Name", "Marks"])
    wr.writerow([12, "Kalesh", 480])
    # Reading from a CSV file
    with open("student.csv", "r") as f:
    reader = csv.reader(f)
    for row in reader:
    print(row)
    Level 2: Data Science & Machine Learning

    3. Essential AI Libraries: NumPy, Pandas & Scikit-Learn

    NumPy (Numerical Python)

    pip install numpy

    Core package for multidimensional arrays. Features homogeneous ndarray structures that execute vectorized numerical calculations orders of magnitude faster than Python lists.

    import numpy as np
    scores = np.array([[99, 88, 77], [44, 55, 66]])
    print("Mean score:", np.mean(scores))

    Pandas (Panel Data Analysis)

    pip install pandas

    Built on top of NumPy for tabular data manipulation. Features 1D Series and 2D DataFrames with labeled rows and columns.

    Attributes & Methods:df.head(2), df.tail(2), df.shape, df.dtypes, df.columns, df.index
    Missing Values & Selection:df.isnull().sum(), df.dropna(), df.fillna(0), df.loc[] (label), df.iloc[] (index)

    Scikit-Learn (Iris Dataset & KNN Workflow)

    pip install scikit-learn

    The premier machine learning library. The official CBSE curriculum prescribes loading the Iris dataset (150 flowers, 4 features: sepal/petal length/width across Setosa, Versicolor, Virginica) and training a KNeighborsClassifier (K=3):

    from sklearn.datasets import load_iris
    from sklearn.model_selection import train_test_split
    from sklearn.neighbors import KNeighborsClassifier
    from sklearn import metrics
    # 1. Load data & 2. Train-test split (80:20)
    iris = load_iris()
    X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.2, random_state=1)
    # 3. Fit KNN & 4. Evaluate
    knn = KNeighborsClassifier(n_neighbors=3)
    knn.fit(X_train, y_train)
    y_pred = knn.predict(X_test)
    print("Accuracy:", metrics.accuracy_score(y_test, y_pred))
    Board Exam Practice • 15 Questions

    Official Handbook MCQs & Answer Key

    Click any option to instantly see if you're correct with the official CBSE explanation.

    1

    Identify the datatype of L in Python: L = "45"

    2

    Which of the following functions converts a string to an integer in Python?

    3

    Which special symbol is used to write single-line comments in Python?

    4

    Which of the following variable identifiers is valid in Python?

    5

    Elements in a Python list are enclosed within which brackets?

    6

    In Python negative indexing, what is the index value of the last element in a list?

    7

    What will be the output of: a = [10, 20, 30, 40, 50]; print(a[0])?

    8

    Name the built-in function that displays the data type of a variable in Python.

    9

    Which standard Python library module helps in manipulating Comma Separated Values files?

    10

    Which control flow keyword is used to terminate a loop prematurely in Python?

    11

    What is the primary data structure used in NumPy to represent arrays of any dimension?

    12

    Which of the following is NOT a standard method to access elements of a Pandas DataFrame?

    13

    What is the purpose of the head() method in a Pandas DataFrame?

    14

    Which method is used to remove rows containing missing (NaN) values from a Pandas DataFrame?

    15

    Which of the following is NOT a submodule of Scikit-Learn (sklearn)?

    Fast Revision Summary

    Unit 3 Quick Recall Cheat Sheet

    Python Tokens: Keywords, Identifiers, Literals, Operators, and Punctuators form the atomic lexical units.
    NumPy ndarray: Homogeneous multidimensional array enabling fast vectorized mathematical operations.
    Pandas DataFrame: 2D labeled tabular data; .loc[] selects by label, .iloc[] by integer position.
    Missing Values: Represented as NaN; detected with isnull(), removed with dropna(), filled with fillna().
    Iris Classification: 4 features (sepal/petal dimensions) predict 3 flower species using KNeighborsClassifier(n_neighbors=3).
    Train-Test Split: Standard ratio 80:20 (test_size=0.2); random_state guarantees reproducible splits.
    Clear Your Doubts

    Frequently Asked Questions (FAQ)

    Ace Your Practical & Board Exams • Subject 843

    Master Python for AI & Data Science with 1:1 Mentorship

    Build real-world data pipelines and train classification models. Get live 1-on-1 coding mentorship from certified AI educators to master NumPy, Pandas, Scikit-learn, and ace your Class 11 AI practical exam.