Class 10 AI Unit 7: Advance Python – Notes (Jupyter, Python Basics, Libraries) | CBSE Code 417
Jupyter Notebook, virtual environments, Python basics, built-in functions and the libraries you'll use in your practical file.
Unit 7 has no theory marks, but it's the backbone of your practical file (15 programs) and practical exam. Weak Python = a tough practical exam. So practise every snippet on this page yourself.
- Jupyter Notebook and Anaconda
- Virtual environments and installing packages
- Python fundamentals: variables, data types, operators
- Decisions and loops
- Lists and built-in functions
- Libraries for AI: NumPy, Pandas, Matplotlib, OpenCV
If AI is a car, Python is the steering wheel. Almost every AI tool (TensorFlow, OpenCV, ChatGPT's training code) talks Python. The good news: Python reads almost like English. if marks > 33: print("Pass") — you can probably guess what that does already!
1. Jupyter Notebook
Jupyter Notebook is a web-based tool where you write and run Python code in small blocks called cells, and see the output right below each cell. You can also add notes, headings and charts. It's perfect for AI and data science because you can test step by step.
- Code cell: contains Python code. Press Shift + Enter to run it.
- Markdown cell: contains text, headings and notes.
- Files are saved with the extension .ipynb (IPython Notebook).
Anaconda is a free distribution that installs Python, Jupyter Notebook and hundreds of data-science libraries together. You can also use Google Colab in the browser without installing anything.
2. Virtual Environments and Packages
You don't carry your cricket kit in your school bag. A virtual environment is like a separate bag for each project: it keeps that project's Python version and libraries separate, so one project's packages don't clash with another's.
3. Python Fundamentals
Variables and data types
Operators
| Type | Operators | Example (x = 7) |
|---|---|---|
| Arithmetic | + − * / // % ** | x // 2 = 3, x % 2 = 1, x ** 2 = 49 |
| Comparison | == != > < >= <= | x > 5 → True |
| Logical | and, or, not | x > 5 and x < 10 → True |
| Assignment | = += -= *= | x += 3 → x becomes 10 |
Input and output
4. Decisions and Loops
▶ Watch a loop run, step by step (auto-play flowchart)
Press nothing — the flowchart runs by itself! Watch the yellow dot travel, the box that is working light up, and the variables change. Use the buttons to pause, go one step at a time, or switch between a for loop and a while loop.
Every loop has 4 parts: ① start value (i = 1) → ② condition check (i ≤ 5?) → ③ body (the work) → ④ update (i = i + 1), then back to the check. When the condition becomes False, the loop stops. In a while loop, if you forget step ④, the condition never becomes False — that's an infinite loop!
1) Forgetting the colon : after if/for. 2) Wrong indentation — Python uses spaces to group code. 3) range(1, 6) stops at 5, not 6.
5. Lists and Built-in Functions
marks.append(70) adds a new box at the end.| Built-in function | Use |
|---|---|
print(), input() | Show output / take input |
len(), max(), min(), sum() | Length, largest, smallest, total |
type(), int(), float(), str() | Check / convert data type |
range(), round(), sorted() | Number sequence, rounding, sorted copy |
Mean, median, mode (a practical-file favourite)
6. Python Libraries for AI
NumPy
Fast maths on arrays/matrices. import numpy as np
Pandas
Read and analyse tables and CSV files. import pandas as pd
Matplotlib
Draw line, bar, scatter and pie charts. import matplotlib.pyplot as plt
OpenCV
Read, display and edit images. import cv2
plt.show() displays: the line draws from test to test, just like the code above.Viva Practice
Q1. What is the extension of a Jupyter Notebook file?
.ipynb
Q2. Why do we create a virtual environment?
To keep each project's Python version and packages separate and avoid clashes.
Q3. Which library is used to read CSV files?
Pandas — pd.read_csv()
Q4. Output of 7 // 2 and 7 % 2?
3 and 1
⚡ One-minute revision
- Jupyter = cells (code + markdown), Shift+Enter runs, saved as .ipynb.
- Virtual environment keeps project packages separate; install with
pip install. - Data types: int, float, str, bool. Operators: arithmetic, comparison, logical, assignment.
- if / elif / else for decisions; for / while for loops.
- Lists + built-ins: len, max, min, sum, sorted, append.
- Libraries: NumPy, Pandas, Matplotlib, OpenCV.
Done reading? Test yourself on AI Unit 7 in board-exam style.
๐ Take the Practice PaperNext: ES Unit 1 ›๐ Class 10 Hub
Comments
Post a Comment