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.
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:
Reserved words with special meaning (e.g., False, None, True, def, if, elif, for, while, import, break).
User-defined names for variables, functions, and classes. Cannot start with a digit or contain special characters except underscore (_).
Raw fixed data values: String ("Ria"), Numeric (10, 5.5), Boolean (True/False), and Special (None).
Symbols triggering computations: Arithmetic (+,-,*,/,%), Relational (==,!=,<,>), Logical (and,or,not), Identity (is), and Membership (in).
Organizing delimiters: : , ( ) [ ] { } ; . " '
Variables can hold different types during execution without explicit redeclaration. Type casting is done via int(), float(), str().
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).
3. Essential AI Libraries: NumPy, Pandas & Scikit-Learn
NumPy (Numerical Python)
pip install numpyCore package for multidimensional arrays. Features homogeneous ndarray structures that execute vectorized numerical calculations orders of magnitude faster than Python lists.
scores = np.array([[99, 88, 77], [44, 55, 66]])
print("Mean score:", np.mean(scores))
Pandas (Panel Data Analysis)
pip install pandasBuilt on top of NumPy for tabular data manipulation. Features 1D Series and 2D DataFrames with labeled rows and columns.
df.head(2), df.tail(2), df.shape, df.dtypes, df.columns, df.indexdf.isnull().sum(), df.dropna(), df.fillna(0), df.loc[] (label), df.iloc[] (index)Scikit-Learn (Iris Dataset & KNN Workflow)
pip install scikit-learnThe 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):
Official Handbook MCQs & Answer Key
Click any option to instantly see if you're correct with the official CBSE explanation.
Identify the datatype of L in Python: L = "45"
Which of the following functions converts a string to an integer in Python?
Which special symbol is used to write single-line comments in Python?
Which of the following variable identifiers is valid in Python?
Elements in a Python list are enclosed within which brackets?
In Python negative indexing, what is the index value of the last element in a list?
What will be the output of: a = [10, 20, 30, 40, 50]; print(a[0])?
Name the built-in function that displays the data type of a variable in Python.
Which standard Python library module helps in manipulating Comma Separated Values files?
Which control flow keyword is used to terminate a loop prematurely in Python?
What is the primary data structure used in NumPy to represent arrays of any dimension?
Which of the following is NOT a standard method to access elements of a Pandas DataFrame?
What is the purpose of the head() method in a Pandas DataFrame?
Which method is used to remove rows containing missing (NaN) values from a Pandas DataFrame?
Which of the following is NOT a submodule of Scikit-Learn (sklearn)?
Unit 3 Quick Recall Cheat Sheet
.loc[] selects by label, .iloc[] by integer position.NaN; detected with isnull(), removed with dropna(), filled with fillna().KNeighborsClassifier(n_neighbors=3).test_size=0.2); random_state guarantees reproducible splits.Frequently Asked Questions (FAQ)
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.