Curriculum
Course: Grade X AI(417)
Login
Text lesson

Unit 3-Advance Python

School Revise · Class 10 Artificial Intelligence · Unit 3

Advance Python

Code 417, Class 10. AI is built with Python. Here we use packages, and the NumPy and Pandas libraries for data.

packages

extra tools

NumPy Pandas

handle data

What this unit is about

Beyond the basics, Python uses packages (extra libraries) for AI. Two key ones are NumPy (number arrays) and Pandas (data tables).

1. Packages and imports

A package is a set of ready made tools. We use one with import, for example import numpy as np. Jupyter Notebook is a popular place to write and run AI code.

import numpy as np a = np.array([1, 2, 3]) print(a.sum()) Output: 6

2. NumPy

NumPy works with arrays of numbers and is fast for maths. a.sum(), a.mean() and a.max() summarise an array quickly.

3. Pandas

Pandas handles data in tables. A DataFrame is a table; df[“col”].mean() gives an average and df.groupby summarises groups, ready for a model.

Practise with the interactive

Explore the idea by tapping. The interactive opens right here in the lesson.

Try it in the code lab

Write and run real Python right here in the lesson, then work through the practice problems with answers.

Starting Python...

Coding practice problems, with answers

Type each one into the code lab above, then open the card to see the worked solution and its output.

Problem 1. Print a message.

SOLUTION

print(“AI with Python”)

OUTPUT

AI with Python
Problem 2. Make a NumPy array and sum it.

SOLUTION

import numpy as np a = np.array([1, 2, 3, 4]) print(a.sum())

OUTPUT

10
Problem 3. Find the mean with NumPy.

SOLUTION

import numpy as np a = np.array([2, 4, 6]) print(a.mean())

OUTPUT

4.0
Problem 4. Find the max with NumPy.

SOLUTION

import numpy as np a = np.array([3, 9, 5]) print(a.max())

OUTPUT

9
Problem 5. Make a Pandas Series.

SOLUTION

import pandas as pd s = pd.Series([10, 20, 30]) print(s.tolist())

OUTPUT

[10, 20, 30]
Problem 6. Make a Pandas DataFrame.

SOLUTION

import pandas as pd df = pd.DataFrame({“marks”: [80, 90, 70]}) print(df[“marks”].mean())

OUTPUT

80.0
Problem 7. Group and average with Pandas.

SOLUTION

import pandas as pd df = pd.DataFrame({“cls”: [“A”, “A”, “B”], “m”: [80, 90, 70]}) print(df.groupby(“cls”)[“m”].mean().tolist())

OUTPUT

[85.0, 70.0]
Problem 8. Loop through a list.

SOLUTION

for x in [1, 2, 3]: print(x)

OUTPUT

1 2 3
Problem 9. Build a list of squares.

SOLUTION

sq = [x * x for x in range(1, 4)] print(sq)

OUTPUT

[1, 4, 9]
Problem 10. Count values in a Pandas column.

SOLUTION

import pandas as pd df = pd.DataFrame({“m”: [80, 90, 70]}) print(df[“m”].count())

OUTPUT

3

Practice set A, multiple choice

1. A set of ready made tools is a …

package (library).

2. Which library works with number arrays?

NumPy.

3. Which handles data tables?

Pandas.

4. Which keyword adds a package?

import.

Quick summary

AI is built with Python and its packages. A package is a set of ready made tools, added with import. NumPy works with arrays of numbers and is fast for maths (sum, mean, max). Pandas handles data in tables: a DataFrame holds rows and columns, mean gives an average and groupby summarises groups, ready for a model.

Open the Virtual Lab

These free Class 10 Artificial Intelligence (Code 417) notes explain advanced Python for AI, packages and imports, and the NumPy and Pandas libraries with clear examples and practice, for CBSE students across India and the Gulf including the UAE, Saudi Arabia, Qatar, Oman, Kuwait and Bahrain.

© 2026 School Revise. All rights reserved. Original content aligned to the CBSE and NCERT Class 10 Artificial Intelligence syllabus. Unauthorised copying is not permitted.

Layer 1
Login Categories