Home › Class 12 Skill Subjects › AI 843 › MCQs

Artificial Intelligence (843): Class 12 MCQs

For CBSE Class 12 Artificial Intelligence (843), Part B (theory 40 marks). Questions are written from the CBSE AI Student Handbook, unit by unit. Tap an option to check it; every answer comes with the reason. Every code-output answer was produced by running the code with the same library versions as Google Colab.

Unit 1: Python Programming-II

This unit is assessed in practicals only (lab test, practical file and viva), not in the theory paper. Use these MCQs to prepare for the lab test and viva.

Knowledge MCQs

Direct questions on facts, terms and functions from the handbook.

Q11.1 Python libraries: NumPy recap

Python libraries are best described as:

Q21.1 Python libraries: NumPy recap

NumPy stands for:

Q31.1 Python libraries: NumPy recap

In NumPy, the number of dimensions of an array is called its:

Q41.1 Python libraries: NumPy recap

Which two libraries does the textbook call the backbone of data manipulation and analysis in Python?

Q51.1 Python libraries: NumPy recap

Which library does the textbook mention for visualising sales performance of marketing campaigns?

Q61.1 Python libraries: NumPy recap

NumPy is described in the textbook as a:

Q71.1 Pandas: Series and DataFrame creation

Which two data structures does Pandas generally provide?

Q81.1 Pandas: Series and DataFrame creation

Which of the following is a primary data structure in Pandas?

Q91.1 Pandas: Series and DataFrame creation

When a DataFrame is created from a dictionary of lists, the dictionary keys become:

Q101.1 Pandas: Series and DataFrame creation

When a DataFrame is created from a list of dictionaries, the number of rows equals:

Q111.1 Pandas: Series and DataFrame creation

What is the standard alias used when importing Pandas?

Q121.1 Pandas: Series and DataFrame creation

A DataFrame is a:

Q131.1 Rows, columns and attributes

To delete a ROW using drop(), the parameter axis is set to:

Q141.1 Rows, columns and attributes

To delete a COLUMN using drop(), the parameter axis is set to:

Q151.1 Rows, columns and attributes

Which accessor is used to add a new row, or change a row's values, using its label?

Q161.1 Rows, columns and attributes

Which DataFrame attribute returns the number of rows and columns?

Q171.1 Rows, columns and attributes

Which DataFrame attribute returns the column labels?

Q181.1 Rows, columns and attributes

df.head(n) returns:

Q191.1 Rows, columns and attributes

Which attribute returns the row labels of a DataFrame?

Q201.2 Import and export CSV

CSV stands for:

Q211.2 Import and export CSV

Which function imports a CSV file into a DataFrame?

Q221.2 Import and export CSV

Which function exports a DataFrame to a CSV file?

Q231.2 Import and export CSV

In df.to_csv('resultout.csv', index=False), index=False means:

Q241.2 Import and export CSV

In pd.read_csv('marks.csv', sep=',', header=0), header=0 means:

Q251.2 Import and export CSV

In a CSV file, each line represents:

Q261.2 Import and export CSV

On Google Colab, how is a CSV file made available before reading it?

Q271.3–1.4 Handling missing values

What are the two common strategies for handling missing values in the textbook?

Q281.3–1.4 Handling missing values

Which function checks whether values are missing in a DataFrame?

Q291.3–1.4 Handling missing values

Which function drops rows that have missing values?

Q301.3–1.4 Handling missing values

What does fillna(0) do?

Q311.3–1.4 Handling missing values

The textbook warns that dropping rows should be used only when:

Q321.3–1.4 Handling missing values

In a DataFrame, a missing numeric value is shown as:

Q331.3–1.4 Handling missing values

Which of these is NOT an estimation method for missing values mentioned in the textbook?

Q34Practical file: statistical checks on data

Which method generates descriptive statistics such as count, mean and std?

Q35Practical file: statistical checks on data

Which statement displays the LAST 10 records of a DataFrame df, as asked in the practical file?

Q36Practical file: statistical checks on data

Which statement displays the number of missing values in EACH column of df?

Q37Practical file: statistical checks on data

Which function gives the number of non-missing values in each column?

Q38Practical file: statistical checks on data

Which statement fills missing values of df with the mean of each column?

Q39Practical file: statistical checks on data

Which statistical function returns the middle value of a numeric column?

Q40Practical file: statistical checks on data

The curriculum's practical file asks for Python programs from which platforms?

Scenario and code MCQs

Competency-based. Predict the output of code or choose what fits a real situation.

Q411.1 Python libraries: NumPy recapCompetency

What is the output?

arr = np.array([[1, 2, 3], [4, 5, 6]])
print(arr.ndim)
Q421.1 Python libraries: NumPy recapCompetency

What is the output?

arr = np.array((1, 3, 2))
print(arr)
Q431.1 Python libraries: NumPy recapCompetency

What is the output?

arr = np.array([[1, 2, 3], [4, 5, 6]])
print(arr.shape)
Q441.1 Python libraries: NumPy recapCompetency

A teacher stores 40 students' marks and wants the class average in one line. Which is the most suitable?

Q451.1 Python libraries: NumPy recapCompetency

What is the output?

marks = np.array([70, 80, 90])
print(marks + 5)
Q461.1 Pandas: Series and DataFrame creationCompetency

What is the output?

series1 = pd.Series([10, 20, 30])
print(series1[1])
Q471.1 Pandas: Series and DataFrame creationCompetency

What is the output?

data = {'a': 1, 'b': 2, 'c': 3}
s = pd.Series(data)
print(s['b'])
Q481.1 Pandas: Series and DataFrame creationCompetency

What is the output?

a1 = np.array([90, 100, 110, 120])
a2 = np.array([50, 60, 70])
a3 = np.array([10, 20, 30, 40])
marksDF = pd.DataFrame([a1, a2, a3], columns=['A','B','C','D'])
print(marksDF.loc[1, 'D'])
Q491.1 Pandas: Series and DataFrame creationCompetency

In the output of the previous example (arrays of lengths 4, 3 and 4), why does column D show 120.0 and 40.0 instead of 120 and 40?

Q501.1 Pandas: Series and DataFrame creationCompetency

What is the output?

listDict = [{'a': 10, 'b': 20}, {'a': 5, 'b': 10, 'c': 20}]
a = pd.DataFrame(listDict)
print(a.shape)
Q511.1 Pandas: Series and DataFrame creationCompetency

What is the output?

data = {'Name': ['Varun', 'Ganesh', 'Joseph'], 'Age': [37, 30, 38]}
df = pd.DataFrame(data)
print(list(df.columns))
Q521.1 Pandas: Series and DataFrame creationCompetency

A shop has product names in one list and prices in another. Which is the simplest way to build a table from them?

Q531.1 Rows, columns and attributesCompetency

What is the output?

df = pd.DataFrame({'Student': ['Arnav','Neha','Priya','Rahul'], 'Marks': [85,92,78,83],
                   'Sports': ['Cricket','Volleyball','Hockey','Badminton']},
                  index=['Data 1','Data 2','Data 3','Data 4'])
print(df.shape)
Q541.1 Rows, columns and attributesCompetency

What is the output?

df = pd.DataFrame({'Student': ['Arnav','Neha','Priya','Rahul'], 'Marks': [85,92,78,83],
                   'Sports': ['Cricket','Volleyball','Hockey','Badminton']},
                  index=['Data 1','Data 2','Data 3','Data 4'])
print(df.tail(1)['Student'].values[0])
Q551.1 Rows, columns and attributesCompetency

What is the output?

df = pd.DataFrame({'Student': ['Arnav','Neha','Priya','Rahul'], 'Marks': [85,92,78,83],
                   'Sports': ['Cricket','Volleyball','Hockey','Badminton']},
                  index=['Data 1','Data 2','Data 3','Data 4'])
print(len(df.head(2)))
Q561.1 Rows, columns and attributesCompetency

A Result DataFrame has subjects as rows (Maths, Science, Hindi) and students as columns. Fathima's marks must be added. Which statement is correct?

Q571.1 Rows, columns and attributesCompetency

In the same Result DataFrame (subjects as rows), how do you add marks for English?

Q581.1 Rows, columns and attributesCompetency

What is the output?

R = pd.DataFrame({'Rajat': [90, 91, 97], 'Amrita': [92, 81, 96]},
                 index=['Maths', 'Science', 'Hindi'])
R = R.drop('Hindi', axis=0)
print(list(R.index))
Q591.1 Rows, columns and attributesCompetency

A student writes Result.drop('Rajat') to remove the column Rajat and gets a KeyError. Why?

Q601.1 Rows, columns and attributesCompetency

What is the output?

R = pd.DataFrame({'Rajat': [90, 91], 'Amrita': [92, 81]}, index=['Maths', 'Science'])
R.loc['Science'] = [95, 85]
print(R.loc['Science', 'Amrita'])
Q611.2 Import and export CSVCompetency

Asha's teacher gives her 'studentmarks.csv' on Google Colab. What should she do first?

Q621.2 Import and export CSVCompetency

Ravi saves his DataFrame with df.to_csv('out.csv') and finds an extra unnamed first column when he opens it. What should he change?

Q631.2 Import and export CSVCompetency

On a Windows computer, the file is at C:/PANDAS/studentsmarks.csv. Which call reads it correctly?

Q641.2 Import and export CSVCompetency

A file uses semicolons between values (e.g. Amit;85;90). How should it be read?

Q651.3–1.4 Handling missing valuesCompetency

How many missing values are in the marks DataFrame of the case study (Meera—Science, Suhana—Hindi, Joseph—AI)?

print(marks.isnull().sum().sum())
Q661.3–1.4 Handling missing valuesCompetency

After drop = marks.dropna() on the case-study marks, how many rows remain?

print(len(marks.dropna()))
Q671.3–1.4 Handling missing valuesCompetency

What does this print for the case-study marks?

print(marks['Maths'].isnull().any())
Q681.3–1.4 Handling missing valuesCompetency

A student fills Meera's missing Science marks with the column average. Which statement does it?

Q691.3–1.4 Handling missing valuesCompetency

What value replaces Meera's missing Science marks if the column mean is used?

print(marks['Science'].fillna(marks['Science'].mean())['Meera'])
Q701.3–1.4 Handling missing valuesCompetency

Joseph missed the AI exam to attend a national science exhibition. Which is the fairest way to handle his missing AI mark for class analysis?

Assertion–Reason

Competency-based. Decide whether each statement is true, and whether the Reason explains the Assertion.

Q711.1 Pandas: Series and DataFrame creationCompetency

Assertion (A): A DataFrame can hold different data types in different columns.

Reason (R): Each column of a DataFrame is like a Series with its own data type.

Q721.1 Pandas: Series and DataFrame creationCompetency

Assertion (A): In a DataFrame created from a dictionary of lists, the lists become the columns.

Reason (R): The dictionary keys become the row labels.

Q731.1 Rows, columns and attributesCompetency

Assertion (A): Result.drop('Hindi', axis=0) removes the row labelled Hindi.

Reason (R): axis=1 is used to delete rows.

Q741.2 Import and export CSVCompetency

Assertion (A): CSV files are widely used for storing tabular data.

Reason (R): They are simple text files that are easy for both humans and computers to read and write.

Q751.2 Import and export CSVCompetency

Assertion (A): df.to_csv('out.csv', index=False) writes the row labels to the file.

Reason (R): to_csv() saves a DataFrame to a text or CSV file.

Q761.3–1.4 Handling missing valuesCompetency

Assertion (A): Dropping rows with missing values is suitable when many rows have missing values.

Reason (R): Dropping reduces the size of the dataset.

Q771.3–1.4 Handling missing valuesCompetency

Assertion (A): fillna(0) and dropna() both remove missing values from view.

Reason (R): isnull() returns True where a value is missing.

Q781.3–1.4 Handling missing valuesCompetency

Assertion (A): np.NaN, as printed in the textbook, gives an error in NumPy 2.0.

Reason (R): NumPy 2.0 removed the alias np.NaN; np.nan must be used.

Q79Practical file: statistical checks on dataCompetency

Assertion (A): df.describe() does not count missing values in its count row.

Reason (R): describe() excludes NaN values when summarising a column.

Q80Practical file: statistical checks on dataCompetency

Assertion (A): df.isnull().sum().sum() returns a single number.

Reason (R): The first sum() counts NaN per column and the second adds those counts.

Case-based questions

Competency-based. Read the situation once, then answer the four questions that follow.

1.1 Pandas: Series and DataFrame creationCompetency

A student runs this code:

a1 = np.array([90, 100, 110, 120])
a2 = np.array([50, 60, 70])
a3 = np.array([10, 20, 30, 40])
marksDF = pd.DataFrame([a1, a2, a3], columns=['A', 'B', 'C', 'D'])
print(marksDF)
Q81

How many rows does marksDF have?

Q82

What appears in row 1, column D?

Q83

What is the data type of column D?

Q84

What does marksDF.isnull().sum().sum() return?

1.1 Rows, columns and attributesCompetency

A DataFrame df has index ['Data 1','Data 2','Data 3','Data 4'] and columns Student, Marks, Sports for Arnav (85, Cricket), Neha (92, Volleyball), Priya (78, Hockey) and Rahul (83, Badminton).

Q85

df.shape returns:

Q86

df.head(2) shows the rows of:

Q87

Which statement adds a column Grade?

Q88

Which statement removes the Sports column?

1.2 Import and export CSVCompetency

A shopkeeper keeps sales in 'sales.csv' with columns Product and Sales. He wants the total sales of each product saved in a new file.

Q89

Which statement loads the file?

Q90

Which statement computes the totals?

Q91

Which statement saves the result?

Q92

If the file has three rows: (Pen, 10), (Book, 50), (Pen, 15), what is Pen's total?

1.3–1.4 Handling missing valuesCompetency

A class teacher enters marks in Python:

ResultSheet = {'Maths': pd.Series([90,91,97,89,65,93], index=['Heena','Shefali','Meera','Joseph','Suhana','Bismeet']),
  'Science': pd.Series([92,81,np.nan,87,50,88], index=['Heena','Shefali','Meera','Joseph','Suhana','Bismeet']),
  'English': pd.Series([89,91,88,78,77,82], index=['Heena','Shefali','Meera','Joseph','Suhana','Bismeet']),
  'Hindi': pd.Series([81,71,67,82,np.nan,89], index=['Heena','Shefali','Meera','Joseph','Suhana','Bismeet']),
  'AI': pd.Series([94,95,99,np.nan,96,99], index=['Heena','Shefali','Meera','Joseph','Suhana','Bismeet'])}
marks = pd.DataFrame(ResultSheet)

Meera missed Science (fever), Suhana missed Hindi (fever) and Joseph missed AI (national science exhibition).

Q93

Which statement shows True/False for every cell depending on whether it is missing?

Q94

What is the output of print(marks['Science'].isnull().any())?

Q95

Which students remain after marks.dropna()?

Q96

After FillZero = marks.fillna(0), what is Joseph's AI value?

Practical file: statistical checks on dataCompetency

For a practical file program, a student creates:

df = pd.DataFrame({'Name': ['Ira','Om','Pia','Raj','Sam','Tia'], 'Maths': [78, 92, np.nan, 65, 88, 71],
                   'Science': [81, 85, 90, np.nan, 76, np.nan]})
Q97

What does df.isnull().sum().sum() return?

Q98

What is df['Maths'].count()?

Q99

What is the mean of Maths, rounded to 1 decimal place?

Q100

After df2 = df.fillna(df.mean(numeric_only=True)), what is Raj's Science value?