da4001_2026T2_Q2_NA.pdf
Data Science and AI Lab · Quiz 2 · May 2026
← Course papers · Start practice / exam
Questions and published explanations below are available without starting a test. Some questions may not have a published solution yet.
Question 2 NAT · 2.0 marks
Given the following code snippet, how many **unique values** will be present in the column (Z) of the
resulting DataFrame (df)?
[[IMAGE:1b2b0a0d096d7b2f_2_2]]

A published solution is not available for this question yet.
Question 3 NAT · 2.0 marks
What will be the output of the following code?
[[IMAGE:1b2b0a0d096d7b2f_3_3]]

A published solution is not available for this question yet.
Question 4 NAT · 2.0 marks
A binary classification model is evaluated on a test set of 10 images, classifying each as either
Horse ('H') or Zebra ('Z'). The true labels and the predicted labels are provided below:
[[IMAGE:1b2b0a0d096d7b2f_3_4]]
What is the precision of the model for the "Horse" class?

A published solution is not available for this question yet.
Question 5 NAT · 2.0 marks
An agent's ReAct loop performs 1 initial reasoning step, then 3 more reasoning steps (one after
each of 3 tool calls) — 4 reasoning steps total for one query. Each reasoning step consumes 250
input tokens + 150 output tokens. What is the **total number of tokens** consumed by reasoning
alone for one query?
A published solution is not available for this question yet.
Question 6 MCQ · 2.0 marks
What will be the output of the following code?
[[IMAGE:1b2b0a0d096d7b2f_4_5]]

[8.0, np.nan]
[3.0, 8.0]
[7.0, 6.0]
[8.0, 6.0]
Code will throw an Error
A published solution is not available for this question yet.
Question 7 MCQ · 2.0 marks
An ML practitioner is evaluating a classification model by plotting its training and validation loss
over 100 epochs. Which of the following statements regarding model evaluation and overfitting is
true?
Overfitting is occurring if the validation loss strictly decreases alongside the
training loss.
An overfitted model typically exhibits high bias and low variance.
Early stopping can mitigate overfitting by halting the training process before
the model begins to memorize noise.
Duplicating the training data points is an effective way to reduce model
variance and improve generalization.
A published solution is not available for this question yet.
Question 8 MCQ · 2.0 marks
Which of the following describes the behavior of [[IMAGE:1b2b0a0d096d7b2f_5_6]] in PyTorch
regarding the input activation function?

It expects raw logits.
It requires a Sigmoid output.
It requires a Tanh output.
It requires a Softmax output.
A published solution is not available for this question yet.
Question 9 MCQ · 2.0 marks
When defining a custom layer by subclassing [[IMAGE:1b2b0a0d096d7b2f_5_7]] , which method MUST be implemented
to define the computation?

step
train
forward
backward
A published solution is not available for this question yet.
Question 10 MCQ · 2.0 marks
What is the effect of calling [[IMAGE:1b2b0a0d096d7b2f_6_8]] on a network containing [[IMAGE:1b2b0a0d096d7b2f_6_9]] layers?


Clears the gradient buffer.
Freezes all model weights.
Disables the dropout layers.
Increases dropout probability.
A published solution is not available for this question yet.
Question 11 MCQ · 2.0 marks
What is the primary function of the learnable [[IMAGE:1b2b0a0d096d7b2f_6_10]] token prepended to the input sequence in
the original Vision Transformer architecture?

Its final hidden state at the output of the transformer encoder serves as the
global aggregate representation of the image for the classification task.
It provides spatial coordinate data to allow the model to capture the relative
distances and positions of the different image patches.
It acts as a boundary separator to explicitly distinguish where one flattened 2D
image patch ends and the next begins.
It serves as a padding token to maintain a uniform sequence length when the
model processes images of varying resolutions in a single batch.
A published solution is not available for this question yet.
Question 12 MCQ · 2.0 marks
Which LangChain component is responsible for converting raw LLM responses into structured
Python objects?
[[IMAGE:1b2b0a0d096d7b2f_6_11]]

[[IMAGE:1b2b0a0d096d7b2f_6_12]]

[[IMAGE:1b2b0a0d096d7b2f_6_13]]

[[IMAGE:1b2b0a0d096d7b2f_6_14]]

A published solution is not available for this question yet.
Question 13 MCQ · 2.0 marks
[[IMAGE:1b2b0a0d096d7b2f_7_15]]
With the above configuration, how does the conversation history returned by
[[IMAGE:1b2b0a0d096d7b2f_7_16]] get stored in [[IMAGE:1b2b0a0d096d7b2f_7_17]] variable?



A summarized conversation as a string
A summarized conversation as a list
The complete conversation history as a formatted string
The complete conversation history as a list of message objects
A published solution is not available for this question yet.
Question 14 MCQ · 2.0 marks
Choose the correct option with respect to the following code snippet:
[[IMAGE:1b2b0a0d096d7b2f_7_18]]

[[IMAGE:1b2b0a0d096d7b2f_7_19]] should be [[IMAGE:1b2b0a0d096d7b2f_7_20]] .


[[IMAGE:1b2b0a0d096d7b2f_7_21]] should be [[IMAGE:1b2b0a0d096d7b2f_7_22]] .


[[IMAGE:1b2b0a0d096d7b2f_7_23]] is a list, so this should be [[IMAGE:1b2b0a0d096d7b2f_7_24]] .


There is no issue. This code runs correctly.
A published solution is not available for this question yet.
Question 15 MCQ · 2.0 marks
Fix the broken chain:
[[IMAGE:1b2b0a0d096d7b2f_8_25]]
This throws a [[IMAGE:1b2b0a0d096d7b2f_8_26]] at runtime. What is the correct fix? ( [[IMAGE:1b2b0a0d096d7b2f_8_27]] is a helper function
to format documents.)



The pipe order is reversed - it should be [[IMAGE:1b2b0a0d096d7b2f_8_28]] , since
the retriever must run first (query → docs) before formatting (docs → string).

[[IMAGE:1b2b0a0d096d7b2f_8_29]] should be removed entirely as the context is directly going to
come from retriever.

[[IMAGE:1b2b0a0d096d7b2f_8_30]] should be replaced with [[IMAGE:1b2b0a0d096d7b2f_8_31]] .


[[IMAGE:1b2b0a0d096d7b2f_8_32]] should come before [[IMAGE:1b2b0a0d096d7b2f_8_33]] .


A published solution is not available for this question yet.
Question 16 MCQ · 2.0 marks
A legal-tech startup is building a tool that must always draft contracts using the firm's exact house
style - specific clause phrasing, tone, and formatting conventions that must appear identically in
every document, regardless of the underlying facts. The firm's knowledge (case law, templates)
rarely changes. Which approach is the better primary fit, and why?
RAG, because contracts count as "documents" and RAG works with any
document type.
Fine-tuning, because the requirement is about consistently reproducing a
specific style/behavior in every output, not about injecting frequently-changing factual knowledge.
RAG, because retrieving the firm's past contracts as context at generation time
will reliably force the LLM to match their exact phrasing and formatting every time.
Since the knowledge is mainly static, the team should skip both RAG and fine-
tuning and just use a long, detailed system prompt with the house style rules.
A published solution is not available for this question yet.
Question 17 NAT · 3.0 marks
Consider the following Python code snippet that defines the true class labels and the predicted
probabilities for a batch of four data points:
[[IMAGE:1b2b0a0d096d7b2f_9_34]]
What will be the output of the code snippet? (Round your answer to two decimal places)

A published solution is not available for this question yet.
Question 18 NAT · 3.0 marks
An RGB image of size [[IMAGE:1b2b0a0d096d7b2f_9_35]] is fed into a standard Vision Transformer (ViT). The image is
divided into non-overlapping square patches with a side length of [[IMAGE:1b2b0a0d096d7b2f_9_36]] . Enter the final sequence
length
[[IMAGE:1b2b0a0d096d7b2f_10_37]] of the token embeddings that is input into the transformer encoder.



A published solution is not available for this question yet.
Question 19 NAT · 3.0 marks
Consider the following code:
[[IMAGE:1b2b0a0d096d7b2f_10_38]]
The training dataset contains 960 samples, and there is one GPU.
How many optimizer update steps are performed during training (ignore gradient accumulation
and assume [[IMAGE:1b2b0a0d096d7b2f_10_39]] )?


A published solution is not available for this question yet.
Question 20 MCQ · 3.0 marks
You run the following code using huggingface:
[[IMAGE:1b2b0a0d096d7b2f_11_40]]
What is the structure of the variable [[IMAGE:1b2b0a0d096d7b2f_11_41]] ?


A single dictionary containing overall sentiment for both sentences.
A list of tupples containing the label and sentiment score for both sentences.
A single list containing the final labels for both sentences.
A list of dictionaries, one for each input sentence, each containing a label and
a score.
A published solution is not available for this question yet.
Question 21 MCQ · 3.0 marks
What is the output of the following code?
[[IMAGE:1b2b0a0d096d7b2f_12_42]]

The code Raises an error
[1,2,3,4,2,4,6,8]
[2,4,6,8]
[1,2,3,4]
A published solution is not available for this question yet.
Question 22 MCQ · 3.0 marks
[[IMAGE:1b2b0a0d096d7b2f_12_43]]
Using the default f-string template formatter shown above, what happens if the following line is
executed?
[[IMAGE:1b2b0a0d096d7b2f_13_44]]


It prompts the user to enter the missing value.
It substitutes an empty string.
It returns the template with [[IMAGE:1b2b0a0d096d7b2f_13_45]] unchanged.

It raises a [[IMAGE:1b2b0a0d096d7b2f_13_46]]

A published solution is not available for this question yet.
Question 23 MCQ · 3.0 marks
Consider the following LangGraph router for an email assistant. The graph should:
• Send **high priority** emails to [[IMAGE:1b2b0a0d096d7b2f_13_47]]
• Send **low priority** emails to [[IMAGE:1b2b0a0d096d7b2f_13_48]]
• Send all other emails to [[IMAGE:1b2b0a0d096d7b2f_13_49]]
[[IMAGE:1b2b0a0d096d7b2f_14_50]]
Which of the following options correctly fills **all six blanks**?




(1) [[IMAGE:1b2b0a0d096d7b2f_14_51]] (2) [[IMAGE:1b2b0a0d096d7b2f_14_52]] (3) [[IMAGE:1b2b0a0d096d7b2f_14_53]] (4) [[IMAGE:1b2b0a0d096d7b2f_14_54]] (5)
[[IMAGE:1b2b0a0d096d7b2f_14_55]] (6) [[IMAGE:1b2b0a0d096d7b2f_14_56]]






(1) [[IMAGE:1b2b0a0d096d7b2f_14_57]] (2) [[IMAGE:1b2b0a0d096d7b2f_14_58]] (3) [[IMAGE:1b2b0a0d096d7b2f_14_59]] (4) [[IMAGE:1b2b0a0d096d7b2f_14_60]]
(5) [[IMAGE:1b2b0a0d096d7b2f_14_61]] (6) [[IMAGE:1b2b0a0d096d7b2f_14_62]]






(1) [[IMAGE:1b2b0a0d096d7b2f_14_63]] (2) [[IMAGE:1b2b0a0d096d7b2f_14_64]] (3) [[IMAGE:1b2b0a0d096d7b2f_14_65]] (4)
[[IMAGE:1b2b0a0d096d7b2f_14_66]] (5) [[IMAGE:1b2b0a0d096d7b2f_14_67]] (6) [[IMAGE:1b2b0a0d096d7b2f_14_68]]






(1) [[IMAGE:1b2b0a0d096d7b2f_14_69]] (2) [[IMAGE:1b2b0a0d096d7b2f_14_70]] (3) [[IMAGE:1b2b0a0d096d7b2f_14_71]] (4)
[[IMAGE:1b2b0a0d096d7b2f_14_72]] (5) [[IMAGE:1b2b0a0d096d7b2f_14_73]] (6) [[IMAGE:1b2b0a0d096d7b2f_14_74]]






A published solution is not available for this question yet.
Question 24 MSQ · 2.0 marks
Consider the following code and select the correct statement:
[[IMAGE:1b2b0a0d096d7b2f_15_75]]
Which of the following will be contained in [[IMAGE:1b2b0a0d096d7b2f_15_76]] ?


input_ids
attention_mask
token_type_ids
padding_id
A published solution is not available for this question yet.
Question 25 MSQ · 3.0 marks
A student justifies their chunking choice like this:
"I will set [[IMAGE:1b2b0a0d096d7b2f_15_77]] and [[IMAGE:1b2b0a0d096d7b2f_15_78]] so I get fewer, bigger chunks - that way
retrieval is faster since there's less to search through, and I never lose any context since overlap
does not matter if chunks are big enough."
What is wrong with this reasoning? (Select all that apply)


Nothing is wrong - this is a sound strategy
Bigger chunks reduce the number of vectors to compare, but at that size a
chunk likely mixes multiple unrelated topics, hurting the precision of what gets retrieved.
[[IMAGE:1b2b0a0d096d7b2f_15_79]] risks splitting a relevant idea exactly at a chunk boundary

[[IMAGE:1b2b0a0d096d7b2f_15_80]] is invalid and will throw an error

A published solution is not available for this question yet.
Question 26 MSQ · 4.0 marks
Examine the code below, which is meant to build a LangGraph agent: the [[IMAGE:1b2b0a0d096d7b2f_16_81]] node decides
whether to call a [[IMAGE:1b2b0a0d096d7b2f_16_82]] or finish, based on [[IMAGE:1b2b0a0d096d7b2f_16_83]] .
[[IMAGE:1b2b0a0d096d7b2f_17_84]]
Which of the following statements about this code are **correct**? (Select all that apply)




Replacing [[IMAGE:1b2b0a0d096d7b2f_17_85]] with the string [[IMAGE:1b2b0a0d096d7b2f_17_86]] in the conditional edge mapping would
still terminate the graph correctly.


Replacing [[IMAGE:1b2b0a0d096d7b2f_17_87]] with
[[IMAGE:1b2b0a0d096d7b2f_17_88]] would preserve the same behavior.


If [[IMAGE:1b2b0a0d096d7b2f_18_89]] returned [[IMAGE:1b2b0a0d096d7b2f_18_90]] instead of [[IMAGE:1b2b0a0d096d7b2f_18_91]] without
changing the mapping, execution would fail at runtime.



[[IMAGE:1b2b0a0d096d7b2f_18_92]] is called incorrectly because the mapping
dictionary should come before the routing function.

The graph would behave the same if [[IMAGE:1b2b0a0d096d7b2f_18_93]]
were replaced with [[IMAGE:1b2b0a0d096d7b2f_18_94]] .


The graph correctly loops between [[IMAGE:1b2b0a0d096d7b2f_18_95]] and [[IMAGE:1b2b0a0d096d7b2f_18_96]] until
[[IMAGE:1b2b0a0d096d7b2f_18_97]] returns [[IMAGE:1b2b0a0d096d7b2f_18_98]] .




A published solution is not available for this question yet.