wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Page 1

Total questions: 150

Worksheet time: 1hrs 15mins

Name
Class
Date
1.

Which reason best explains why Python is widely used for AI development?

a)

Rich ecosystem of libraries and tools

b)

Small developer community worldwide

c)

Limited libraries for machine learning tasks

d)

Complex, low-level syntax for control

2.

What percentage in the graphic indicates Python reduces development time?

a)

10% reduction shown

b)

100% reduction shown

c)

40% reduction shown

d)

57% reduction shown

3.

Which item highlights Python’s readable syntax benefit for AI work?

a)

Prioritize complex pointer arithmetic

b)

Emphasize writing long boilerplate code

c)

Require deep memory management throughout

d)

Focus on algorithms, not implementation details

4.

Which statement about Python’s community support is correct?

a)

Minimal documentation is available

b)

Help resources are mostly private

c)

Few forums discuss Python topics

d)

Extensive documentation and tutorials exist

5.

Which library is part of Python’s machine learning ecosystem?

a)

COBOL for business processing

b)

Excel for spreadsheets

c)

Photoshop for image editing

d)

NumPy for numerical computing

6.

What does the slide suggest about Jupyter notebooks?

a)

Used only for large-scale deployment

b)

Replace all other IDEs completely

c)

Designed mainly for hardware testing

d)

Useful for rapid prototyping and sharing

7.

According to the graphic, Python ranks what position for the ML library ecosystem?

a)

#1 position listed

b)

#2 position listed

c)

#3 position listed

d)

#4 position listed

8.

Which phrase matches Python being the primary language of data scientists?

a)

10M+ developers worldwide

b)

57% primary language statistic

c)

#1 ML ecosystem ranking

d)

40% faster development metric

9.

Choose the best explanation for how Python’s libraries help AI projects.

a)

Require building algorithms entirely from scratch

b)

Limit experiments to text processing only

c)

Provide ready-made tools like TensorFlow and scikit-learn

d)

Offer only visualization without computation

10.

Why might beginners prefer Python for AI compared to lower-level languages?

a)

It requires complex compilation steps

b)

It features clean, readable syntax

c)

It hides algorithms behind proprietary code

d)

It forces manual memory allocation always

11.

Which Python method adds a new item to the end of a list?

a)

insert() at index position

b)

append() at list end

c)

concat using plus

d)

extend() with another list

12.

What does features.pop() do when called with no arguments?

a)

removes first element

b)

removes last element

c)

removes middle element

d)

removes all elements

13.

Which expression correctly returns the number of items in a list named features?

a)

size(features) function

b)

count(features) method

c)

len(features) function

d)

length(features) method

14.

Given data = [0,1,2,3,4,5,6,7,8,9], what does data[:8] produce?

a)

elements after index eight

b)

last eight elements

c)

first eight elements

d)

elements 2 through 8

15.

For data = [0,1,2,3,4,5,6,7,8,9], what does data[8:] return?

a)

items after index eight

b)

items excluding index eight

c)

items before index eight

d)

items between five and eight

16.

Which computation implements an 80/20 train split size for a list named data?

a)

round(len(data)*0.5) count

b)

int(len(data)*0.8) count

c)

int(len(data)*0.2) count

d)

len(data)-2 elements

17.

Select the correct Python slice that creates the training subset using an 80/20 split.

a)

data[:int(len(data)*0.8)]

b)

data[int(len(data)*0.2):]

c)

data[int(len(data)*0.8):]

d)

data[:int(len(data)*0.2)]

18.

Why is list slicing important in AI workflows?

a)

trains models automatically

b)

formats images and audio

c)

creates splits and batches

d)

compresses datasets losslessly

19.

Which list best represents labels for a three-class classifier?

a)

["cat","dog","bird"] strings

b)

[1.0,2.0,3.0] numeric

c)

[(1,2),(3,4),(5,6)] tuples

d)

[{x:1},{y:2},{z:3}] dicts

20.

You need to batch data samples for training from a long list. Which operation helps you take contiguous subsets efficiently?

a)

copy by deep clone

b)

shuffle inplace randomly

c)

slice using start stop

d)

map with lambda

21.

Which statement chooses between multiple conditions in Python?

a)

if/elif/else chain

b)

try/except block

c)

def/function header

d)

import/module line

22.

In the shown code, what prints when accuracy equals 0.85?

a)

Excellent model!

b)

Needs improvement

c)

Good model

d)

Training complete

23.

What is the main purpose of a for loop in the example?

a)

Handle runtime errors

b)

Declare model variables

c)

Check convergence repeatedly

d)

Iterate over epochs

24.

Which function is used to get both index and item while looping?

a)

enumerate(data)

b)

range(data)

c)

len(data)

d)

map(data)

25.

When does the while loop continue executing in the example?

a)

While loss > 0.01

b)

Until epoch == 10

c)

While accuracy >= 0.9

d)

Until data list ends

26.

Which keyword immediately exits the current loop as shown?

a)

exit

b)

return

c)

stop

d)

break

27.

What printed message includes the current loop counter in the for loop?

a)

"Training started"

b)

"Needs improvement"

c)

"Excellent model!"

d)

f"Epoch {epoch} complete"

28.

Which loop type is best for a known number of repetitions like epochs?

a)

for loop with range

b)

while loop with condition

c)

do-while loop construct

d)

recursion over function

29.

Which control flow fits repeated updates until a threshold is met?

a)

switch-case block

b)

function definition

c)

for loop over range

d)

while loop

30.

If accuracy is 0.92, which branch runs in the conditional?

a)

else default block

b)

None of the branches

c)

elif accuracy >= 0.8

d)

if accuracy >= 0.9

31.

Which syntax correctly represents a basic Python list comprehension that produces values from an expression over an iterable?

a)

(expression for item in iterable)

b)

expression for item in iterable

c)

{expression for item in iterable}

d)

[expression for item in iterable]

32.

What is the correct syntax to include a filtering condition in a Python list comprehension?

a)

[expression for item in iterable if condition]

b)

[expression if condition for item in iterable]

c)

[if condition expression for item in iterable]

d)

[expression for if condition in iterable]

33.

Given range(10), which list comprehension builds squares of numbers 0 through 9?

a)

[x2forxinrange(10)][x^2 for x in range(10)]

b)

[x*x for x in range(9)]

c)

[x**2 for x in range(10)]

d)

[square(x) for x in range(10)]

34.

A traditional loop creates squares by appending x**2 to a list for x in range(10). Which outcome matches that approach?

a)

[0, 1, 4, 9, 16, ...]

b)

[1, 4, 9, 16, 25, ...]

c)

[0, 2, 4, 6, 8, ...]

d)

[1, 3, 5, 7, 9, ...]

35.

Which benefit is highlighted when using a list comprehension instead of a multi-line loop for building a list?

a)

Same result with less code

b)

Guaranteed lower memory use

c)

Faster CPU clock speed

d)

Automatic parallel execution

36.

Choose the list comprehension that scales features using min-max normalization with min_val and range_val.

a)

[(x + min_val) / range_val for x in features]

b)

[(x - min_val) / range_val for x in features]

c)

[(min_val - x) * range_val for x in features]

d)

[x / (min_val + range_val) for x in features]

37.

Select the comprehension that filters samples to keep only those with a non-None 'label' field.

a)

[s for s in samples if s['label'] is not None]

b)

[s for s in samples if label exists]

c)

[s for s in samples where s['label'] != None]

d)

[s in samples if s['label'] is not None]

38.

Which part of the comprehension [x**2 for x in range(10)] is the iterable being traversed?

a)

range(10)

b)

x**2

c)

x

d)

for

39.

You need the squares of even numbers under 10. Which comprehension correctly does this in one line?

a)

[x**2 for x in range(10) if x % 2 == 0]

b)

[x**2 if x % 2 == 0 for x in range(10)]

c)

[x**2 for x if x % 2 == 0 in range(10)]

d)

[x**2 for x in range(10) when even]

40.

A teammate wrote squares = []; for x in range(10): squares.append(x**2). What is an equivalent, more concise one-line version?

a)

[x**2 for x in range(10)]

b)

list(x**2 for x in range(10))

c)

{x**2 for x in range(10)}

d)

map(lambda x: x**2, range(10))

41.

Which Python method converts all letters in a string to lowercase?

a)

text.split()

b)

text.upper()

c)

text.lower()

d)

text.strip()

42.

After applying strip() to the string ' Hello World ', what is the result?

a)

'Hello World'

b)

['Hello','World']

c)

'hello world'

d)

'HELLO WORLD'

43.

Which method would you use to turn a sentence into a list of words separated by spaces?

a)

lower()

b)

upper()

c)

split()

d)

replace()

44.

In text.replace("o","0"), what change is made to the text?

a)

Remove all zeros

b)

Change zeros to letters

c)

Replace o with zero

d)

Insert extra spaces

45.

What is the typical first step in an NLP preprocessing pipeline for text?

a)

Remove punctuation

b)

Tokenize into characters

c)

Count word frequencies

d)

Convert to lowercase

46.

Which sequence best matches the shown preprocess function steps?

a)

Uppercase, tokenize, pad

b)

Strip, uppercase, join

c)

Lowercase, strip, split

d)

Split, lowercase, strip

47.

Why are string operations important in NLP before training models?

a)

They clean text data

b)

They increase dataset size

c)

They store GPU settings

d)

They replace models entirely

48.

Given model = "ResNet" and acc = 0.956, what does print(f"{model}: {acc:.2%}") output?

a)

ResNet: 0.96

b)

ResNet: 95.60%

c)

ResNet: 95%

d)

ResNet: 95.6

49.

What will print(f"Epoch {epoch:03d}/100") display when epoch is 5?

a)

Epoch 5/100

b)

Epoch 005/100

c)

Epoch 05/100

d)

Epoch 0005/100

50.

Which option correctly describes f-strings in Python 3.6+?

a)

A tool to sort lists

b)

A method to split words

c)

A library for neural nets

d)

A way to format strings

51.

What is the main drawback of repeating the same code for multiple datasets?

a)

Lower memory usage overall

b)

Higher bug risk from duplication

c)

Faster execution for each dataset

d)

Improved readability for beginners

52.

Which statement best describes modular code in this context?

a)

Code with more comments than logic

b)

Code that relies on global variables

c)

Code written in one long script

d)

Code split into reusable functions

53.

In the modular version, what do in_path and out_path represent in process_dataset?

a)

Configuration flags for testing

b)

Column names to transform

c)

File paths for input and output

d)

Loop counters

54.

Which step is performed to handle missing values in the dataset?

a)

data.dropna() removes missing rows

b)

data.rename() changes column names

c)

data.isna() prints NA counts

d)

data.fillna() replaces with zeros

55.

What transformation is applied to the 'price' column in the example?

a)

Adding 1.1

b)

Multiplying by 1.1

c)

Rounding to nearest 1.1

d)

Dividing by 1.1

56.

Why is the modular function easier to test than repeated code?

a)

It eliminates the need for parameters

b)

It uses fewer variables overall

c)

It consolidates logic into a single unit

d)

It avoids reading any files at all

57.

What does save_csv(data, out_path) accomplish in the workflow?

a)

Deletes temporary variables

b)

Displays data statistics

c)

Writes cleaned data to a file

d)

Loads data from disk

58.

Which benefit is highlighted under 'Solution' when using a single function?

a)

Guaranteed faster runtime

b)

No need for code comments

c)

Single function to update

d)

Automatic GPU acceleration

59.

If a new cleaning step is required, how would modular code simplify the change?

a)

Change the step in every script

b)

Add the step once inside the function

c)

Create separate copies for each dataset

d)

Disable testing to reduce effort

60.

How many calls are needed after creating process_dataset to handle two datasets?

a)

One call with both paths

b)

Two calls, one per dataset

c)

Three calls including a helper

d)

Multiple calls per transformation

61.

In the code snippet, what does the accuracy function return when labels is empty?

a)

It returns the number of correct pairs

b)

It returns None implicitly

c)

It raises a ValueError exception

d)

It returns zero as a float value

62.

Which Python feature is used in the functions to document expectations for parameters and return types?

a)

Type hints with annotations

b)

Docstrings with examples

c)

Comments with TODO notes

d)

Runtime asserts for checks

63.

What is computed inside accuracy using the expression sum(p == y for p, y in zip(preds, labels))?

a)

Length of predictions list

b)

Count of correct predictions

c)

Mean of prediction errors

d)

Total number of labels

64.

Which module name is suggested for placing these metric utilities?

a)

main.py for scripts

b)

models.py for classes

c)

utils.py for helpers

d)

metrics.py for shared code

65.

What does classification_report return in the provided example?

a)

A dictionary with accuracy only

b)

A string summary of metrics

c)

A tuple of accuracy and loss

d)

A list of per-class recalls

66.

What is the main benefit stated for using shared metric utilities across projects?

a)

They automatically tune hyperparameters

b)

They allow training on larger datasets

c)

They make code run significantly faster

d)

They reduce bugs when comparing models

67.

Why should functions be kept small as noted in the engineering notes?

a)

To avoid importing libraries

b)

To focus on a single concept

c)

To minimize memory usage

d)

To follow object inheritance

68.

Which import statement is shown for using the utilities across projects?

a)

from metrics import accuracy, classification_report

b)

import metrics as m then m.accuracy

c)

import accuracy from metrics

d)

from utils import accuracy as acc

69.

What Python typing types are imported at the top of the example?

a)

Sequence and Dict generics

b)

Optional and Union types

c)

Set and FrozenSet classes

d)

List and Tuple types

70.

What is the overall theme described by the slide title?

a)

Turning scripts into reusable utilities

b)

Designing deep learning architectures

c)

Building web apps with Flask

d)

Optimizing GPU performance in Python

71.

Which Python keyword starts a function definition?

a)

define

b)

func

c)

def

d)

call

72.

What is the main purpose of a docstring inside a function?

a)

Execute the code faster

b)

Import external libraries automatically

c)

Document what the function does

d)

Store global variables forever

73.

In the example, what does calculate_accuracy return?

a)

The total number of predictions

b)

The percentage of correct over total

c)

A list of all correct indices

d)

A boolean showing if all were correct

74.

Which line ensures a function provides a result back to the caller?

a)

print statement in the body

b)

return statement in the body

c)

docstring at the top

d)

import statement at start

75.

Choose the best description of parameters in a function.

a)

Values the function prints

b)

Settings for the Python interpreter

c)

Names listed in the definition

d)

Numbers stored in files

76.

Given correct = 85 and total = 100, what value does calculate_accuracy(correct, total) compute?

a)

85.0

b)

85

c)

0.85

d)

100

77.

Which concept helps reduce code duplication, as highlighted on the slide?

a)

Writing comments everywhere

b)

Encapsulating logic in functions

c)

Copy-pasting similar blocks

d)

Using long scripts repeatedly

78.

What is the role of arguments when calling a function?

a)

They return results automatically

b)

They are values passed to parameters

c)

They define scope rules

d)

They create new keywords

79.

Why is scope and variable lifetime important in functions?

a)

It decides which libraries can be imported

b)

It controls where variables exist and for how long

c)

It sets the size of numbers in memory

d)

It determines how fast code runs

80.

Which code snippet correctly defines a simple function that returns a sum?

a)

def add(a, b): return a + b

b)

add(a, b): def return a + b

c)

function add(a, b) = a + b

d)

def add(a, b) print a + b

81.

Which call uses positional arguments to pass data into a function named train?

a)

train(model="ResNet", lr=0.001, epochs=100)

b)

train(epochs=100, lr=0.001, model="ResNet")

c)

train("ResNet", 100, 0.001)

d)

train(model="ResNet")

82.

What is a keyword argument in a function call?

a)

A return value from the function

b)

A parameter passed with its name specified

c)

A variable defined inside the function

d)

A value matched by position order

83.

Which definition illustrates default parameter values in a function?

a)

def train(model, epochs, lr): pass

b)

def train(model, epochs=100, lr=0.001): pass

c)

def train(): return model

d)

def train(model="ResNet"): pass

84.

In the best practice note, how should parameters be ordered in a function definition?

a)

Required first, optional with defaults last

b)

Largest data types first

c)

Optional first, required last

d)

Alphabetical order always

85.

Given def train(model, epochs=100, lr=0.001): pass, which call uses all defaults except model?

a)

train(model="ResNet", epochs=200)

b)

train("ResNet", 100, 0.001)

c)

train("ResNet")

d)

train(epochs=200)

86.

Which function call overrides just the epochs while keeping other defaults?

a)

train("ResNet", epochs=200)

b)

train(lr=0.001)

c)

train("ResNet", 200, 0.001)

d)

train(model="ResNet")

87.

Why can keyword arguments make function calls clearer?

a)

They allow longer function names

b)

They specify parameter names explicitly

c)

They remove the need for defaults

d)

They enforce strict positional order

88.

Which statement about positional arguments is correct?

a)

They can only be optional

b)

Their order maps to parameter positions

c)

They must match parameter names

d)

They require default values

89.

If epochs has a default of 100, what happens when epochs is not provided in a call?

a)

The function asks the user for input

b)

The function uses epochs equal to 100

c)

The function uses epochs equal to 0

d)

The call fails immediately

90.

A team wants cleaner function calls with optional parameters. What change should they make?

a)

Place optional parameters before required

b)

Use keyword arguments for optional parameters

c)

Remove all default values from definitions

d)

Always call with full positional lists

91.

What does the *args parameter allow a Python function to do?

a)

Return multiple values automatically

b)

Accept any number of positional arguments

c)

Accept any number of keyword arguments

d)

Restrict input to a fixed number of arguments

92.

In the example def sum_all(*numbers): return sum(numbers), what is the role of numbers?

a)

Tuple of positional arguments

b)

List of keyword pairs

c)

Dictionary of settings

d)

Generator of integers

93.

What does the **kwargs parameter collect when used in a function definition?

a)

Set of unique values

b)

Tuple of positional arguments

c)

List of ordered parameters

d)

Dictionary of keyword arguments

94.

Which call correctly passes keyword arguments to create_config(**settings)?

a)

create_config(('lr', 0.01))

b)

create_config(['lr', 'epochs'])

c)

create_config(0.01, 50)

d)

create_config(lr=0.01, epochs=50)

95.

Choose the best reason to use *args in sum_all(1, 2, 3, 4, 5).

a)

Handle variable-length inputs

b)

Ensure static type checking

c)

Force named parameters only

d)

Improve code compilation speed

96.

In build_model(architecture, **hyperparams), what does model.configure(**hyperparams) achieve?

a)

Bind arguments at import time

b)

Ignore unknown parameters safely

c)

Convert settings to positional form

d)

Pass all settings to the model

97.

Which statement about *args and **kwargs is accurate?

a)

*args collects positional, **kwargs collects keyword

b)

Both require fixed-length inputs

c)

*args collects keyword, **kwargs collects positional

d)

Both collect only positional arguments

98.

What is returned by sum_all(1, 2, 3, 4, 5) in the example?

a)

A list of numbers

b)

A tuple of five values

c)

An error due to extra inputs

d)

15 as the sum

99.

Why might **kwargs be helpful when configuring machine learning models?

a)

Allows flexible hyperparameter passing

b)

Prevents runtime memory allocation

c)

Ensures compile-time optimization

d)

Limits models to default settings only

100.

Which function signature enables both fixed and flexible inputs in the example?

a)

build_model(architecture, **hyperparams)

b)

configure_model(*args, **model)

c)

sum_all(numbers, **kwargs)

d)

create_config(*settings, lr)

101.

In Python, what does the get_accuracy function return when given predictions and labels of equal length?

a)

A list of all correct indices

b)

The fraction of correct predictions

c)

The number of correct predictions only

d)

The sum of all label values

102.

Which expression computes the count of correct matches in the shown get_accuracy code?

a)

len(pred) - len(labels)

b)

sum(p == l for p, l in zip(pred, labels))

c)

pred.count(labels)

d)

sum(zip(pred, labels))

103.

What is the main purpose of zip(pred, labels) in the accuracy function?

a)

To sort both lists together

b)

To pair predictions with labels

c)

To remove duplicates from lists

d)

To concatenate two lists

104.

In the train_test_split example, what does int(len(data)*0.8) represent?

a)

The average of the data

b)

The number of labels

c)

The index where to split

d)

The size of the test set

105.

When a function returns two values in Python, how are they received in the example?

a)

By tuple unpacking into two variables

b)

As a single list result

c)

Through a global variable update

d)

By printing both values to console

106.

Which line shows multiple return values from train_test_split?

a)

return data[:split], data[split:]

b)

return data[split:]

c)

return split

d)

return data

107.

In the evaluate(model) example, what data structure is returned?

a)

A tuple of three floats

b)

A list of metric values

c)

A string describing results

d)

A dictionary with named metrics

108.

Why might returning a dictionary of results be helpful, according to the pro tip?

a)

It is faster than tuples

b)

It avoids function calls

c)

It is self-documenting with names

d)

It uses less memory

109.

If train, test = train_test_split(data) fails with a ValueError: not enough values to unpack, what likely changed in the function?

a)

It returns no value now

b)

It prints instead of returns

c)

It uses zip instead of split

d)

It returns only one value

110.

Given evaluate(model) returns {'accuracy': 0.95, 'precision': 0.93, 'recall': 0.94}, which key should you access to get the recall value?

a)

metrics['score']

b)

test['recall']

c)

result['recall']

d)

model['recall']

111.

In Python, where does a local variable defined inside a function exist?

a)

Only inside that function body

b)

Inside built-in namespace

c)

Inside enclosing class scope

d)

Across all modules globally

112.

What happens when print(x) is executed outside the function where x was defined locally?

a)

It raises a NameError

b)

It accesses built-in x

c)

It prints the local value

d)

It returns None silently

113.

Which statement correctly reads a global variable inside a function without modification?

a)

Use it directly by name

b)

Import builtins first

c)

Declare it with global

d)

Pass it as keyword

114.

To modify a global variable inside a function, what must you do first?

a)

Declare it with global

b)

Use nonlocal keyword

c)

Cast it to float

d)

Define it as parameter

115.

Which order describes Python’s LEGB lookup rule?

a)

Local, Enclosing, Global, Built-in

b)

Enclosing, Local, Built-in, Global

c)

Global, Local, Built-in, Enclosing

d)

Built-in, Global, Local, Enclosing

116.

Given learning_rate = 0.001 at module level, what does train() printing learning_rate show if not redefined?

a)

It raises UnboundLocalError

b)

It prints 0.0001

c)

It prints None

d)

It prints 0.001

117.

In update_lr(), why is the line global learning_rate used before assignment?

a)

To prevent return value

b)

To access built-in names

c)

To create a local constant

d)

To modify the module variable

118.

Which practice improves code clarity and testability regarding state changes?

a)

Avoid return statements

b)

Rely on many globals

c)

Pass values as parameters

d)

Use hidden built-ins

119.

Which keyword lets you modify a variable in an enclosing function scope?

a)

static

b)

extern

c)

global

d)

nonlocal

120.

A function assigns learning_rate = 0.0001 without global. There is a module-level learning_rate = 0.001. What is printed inside that function?

a)

An AttributeError

b)

0.001 global value

c)

A built-in default

d)

0.0001 local value

121.

What is the main purpose of a docstring in a function?

a)

Explain algorithmic complexity and performance

b)

Document usage, parameters, returns, and errors

c)

Store runtime logs for debugging sessions

d)

Define default values for all function arguments

122.

In the code sample, which normalization methods are mentioned as valid options?

a)

"average" and "median"

b)

"standard" and "robust"

c)

"minmean" and "maxscore"

d)

"minmax" and "zscore"

123.

Which section of the docstring lists the types and meanings of the function inputs?

a)

Notes section

b)

Args section

c)

Returns section

d)

Raises section

124.

What does the Returns section describe for the normalize function?

a)

A list of normalized values

b)

A dictionary of parameter defaults

c)

A single boolean success flag

d)

A tuple of errors and warnings

125.

According to the slide, which is a benefit of documenting code with docstrings?

a)

Faster compilation of source files

b)

Reduced memory usage at runtime

c)

IDE shows docs on hover

d)

Automatic variable type inference

126.

Which statement best describes the Raises section in a docstring?

a)

It lists environment variables to configure

b)

It lists the external libraries required

c)

It lists exceptions the function may throw

d)

It lists performance benchmarks for the code

127.

If an unrecognized method is passed to normalize, what should happen based on the docstring?

a)

Log a warning and continue

b)

Fallback silently to minmax

c)

Raise ValueError for invalid method

d)

Return None without changes

128.

Why is documentation considered essential for open-source projects?

a)

It optimizes code execution in production

b)

It hides implementation details from contributors

c)

It enables auto-generating API docs and collaboration

d)

It prevents forks and derivative projects

129.

Which docstring style is shown in the code block?

a)

PEP 257 minimal docstring

b)

reStructuredText style docstring

c)

Google style docstring

d)

NumPy style docstring

130.

Which benefit is directly tied to developer experience in IDEs?

a)

IDE shows documentation on hover

b)

Easier maintenance after deployment

c)

Essential for licensing compliance

d)

Self-documenting code when compiled

131.

Which phrase best defines a higher-order function in programming?

a)

A function calling system libraries

b)

A function manipulating raw memory

c)

A function that returns other functions

d)

A function storing global variables

132.

What does apply_to_all(func, data) return when func is lambda x: x**2 and data is [1, 2, 3]?

a)

It returns [3, 5, 7]

b)

It returns [2, 4, 6]

c)

It returns [1, 4, 9]

d)

It returns [1, 2, 3]

133.

In the code, what role does the parameter func play inside apply_to_all?

a)

It is a data type converter

b)

It is a function applied to each item

c)

It is a loop counter variable

d)

It is a number accumulator

134.

Which built-in construct applies a function to every element of a list and produces an iterable?

a)

zip

b)

map

c)

reduce

d)

filter

135.

Which statement best describes filter with lambda x: x > 0 on nums?

a)

It removes duplicate numbers

b)

It sorts numbers by absolute value

c)

It converts nums to lowercase

d)

It keeps only positive numbers

136.

When sorting dictionaries with sorted(data, key=lambda x: x["val"]), what does key specify?

a)

The field used to compare items

b)

The comparison operator used

c)

The type of sorting algorithm

d)

The limit on items returned

137.

Given numbers = [1, 2, 3, 4], which expression produces [2, 4, 6, 8]?

a)

list(filter(lambda x: x%2==0, numbers))

b)

sorted(numbers, key=lambda x: -x)

c)

list(map(lambda x: x+1, numbers))

d)

list(map(lambda x: x*2, numbers))

138.

Which example shows passing a function as an argument?

a)

apply_to_all(lambda x: x**2, numbers)

b)

apply_to_all(data=True, func=False)

c)

apply_to_all(numbers, lambda x: x**2)

d)

apply_to_all(numbers, [1,2,3,4])

139.

Why might AI preprocessing pipelines use higher-order functions?

a)

To store models in global memory

b)

To replace training data entirely

c)

To compose stepwise transformations

d)

To avoid using any loops

140.

Which choice correctly converts all strings in ["a", "b"] to uppercase using a built-in?

a)

list(filter(str.upper, ["a","b"]))

b)

list(map(str.upper, ["a","b"]))

c)

sorted(["a","b"], key=str.upper)

d)

list(map(lambda x: x.lower, ["a","b"]))

141.

What is the primary purpose of a decorator in Python?

a)

Rendering graphics on the screen

b)

Wrapping and extending a function’s behavior

c)

Compiling code to machine instructions

d)

Replacing variables with constant values

142.

In the timing decorator shown, which function actually calls the original function?

a)

timer outside wrapper

b)

wrapper inside timer

c)

train_model directly

d)

time.time utility

143.

Which statement records the start time in the timing decorator code?

a)

return wrapper

b)

print(f"{func.__name__} took ...")

c)

result = func(*args, **kwargs)

d)

start = time.time()

144.

Why does the wrapper use *args and **kwargs when calling func?

a)

To run code only once

b)

To convert arguments to strings

c)

To limit calls to no parameters

d)

To accept any parameters flexibly

145.

In the image’s use cases list, which is NOT a stated common use of decorators?

a)

Authentication checks

b)

Caching results (memoization)

c)

Timing or profiling functions

d)

Rendering 3D graphics

146.

What does the print statement in the timing decorator display?

a)

Number of decorator parameters

b)

Operating system version info

c)

CPU temperature and voltage

d)

Function name and elapsed seconds

147.

Which annotation is used to apply the timing decorator to train_model?

a)

@timer above the function

b)

#timer in a comment

c)

timer() after the function

d)

import timer from time

148.

According to the Decorator Flow diagram, what is the sequence of steps?

a)

Wrapper then timing/logging then function call

b)

Function call then wrapper then timing/logging

c)

Timing/logging then wrapper then function call

d)

Wrapper then function call then timing/logging

149.

Which import is necessary for the timing decorator to work as shown?

a)

import time at the top

b)

import math inside wrapper

c)

from os import path

d)

import random for delays

150.

Which line ensures the original function’s return value is preserved?

a)

print elapsed time to console

b)

return wrapper at function end

c)

start = time.time() before call

d)

return result after printing