You are on page 1of 7

14/11/2023, 19:54 web.wise.

live/v1/student/classes/65373d437b511ca95e6cdb34/tests/654b61ce26f9bd0001c4a10a/start

Only one correct


1) What does the 'yield' statement do in Python?

A) It defines a generator and allows you to pause and resume the function's execution.

B) It is used to break out of a loop.

C) It raises an exception.

D) It returns a value from a function and terminates the function.

Clear

Only one correct


2) What is the result of the following list comprehension in Python: [x for x in [1, 2, 3] if x > 3]?

A) []

B) Error

C) [1]

D) [1, 2, 3]

Clear

Only one correct


3) In Python, what is the primary purpose of the '__init__' method in a class?

A) To finalize the class's definition

B) To define a class's main method.

C) To define a class's destructor.

D) To initialize the class's attributes.

Clear

Only one correct


4) Which data structure from the 'collections' module is a subclass of the built-in dict class and is designed for creating
dictionaries with default values for missing keys?

A) defaultdict

B) namedtuple

C) deque

D) Counter

Clear

https://web.wise.live/v1/student/classes/65373d437b511ca95e6cdb34/tests/654b61ce26f9bd0001c4a10a/start 1/7
14/11/2023, 19:54 web.wise.live/v1/student/classes/65373d437b511ca95e6cdb34/tests/654b61ce26f9bd0001c4a10a/start

Only one correct


5) In Python, can you chain multiple decorators for a single function?

A) Yes, you can apply multiple decorators in any order.

B) Only if the decorators are defined in separate modules.

C) Yes, but the order in which you apply them can affect the behavior.

D) No, you can only apply one decorator to a function.

Clear

Only one correct


6) Which of the following methods can be used to manually advance the execution of a generator to the next 'yield'
statement?

A) advance()

B) iterate()

C) move()

D) next()

Clear

Only one correct


7) Which of the following is an example of valid snake case variable naming in Python?

A) user_name

B) User_Name

C) userName123

D) UserName

Clear

Only one correct


8) What is the primary purpose of the regex module in Python?

A) To perform mathematical calculations.

B) To manipulate strings.

C) To format dates and times.

D) To create regular expressions for pattern matching.

Clear

Only one correct


9) How does Anaconda help data scientists and machine learning engineers?

A) It specializes in web development.

https://web.wise.live/v1/student/classes/65373d437b511ca95e6cdb34/tests/654b61ce26f9bd0001c4a10a/start 2/7
14/11/2023, 19:54 web.wise.live/v1/student/classes/65373d437b511ca95e6cdb34/tests/654b61ce26f9bd0001c4a10a/start

B) It offers guided tours of the Amazon rainforest.

C) It focuses on game development.

D) It provides a collection of powerful libraries and tools for data analysis and machine learning.

Clear

Only one correct


10) Which of the following is true about Python's 'map()' function?

A) It is used to define generator functions.

B) It can only be used with numerical data.

C) It applies a given function to each item of an iterable and returns an iterable.

D) It returns a list of the same length as the input list.

Clear

Only one correct


11) In Python, how are blocks of code defined?

A) By using curly braces.

B) By using colons.

C) By using indentation.

D) By using parentheses.

Clear

Only one correct


12) In Python, what does the term "polymorphism" mean in the context of classes?

A) It refers to a class being able to inherit from multiple parent classes.

B) It is a keyword for defining functions.

C) It means that different classes can be treated as instances of the same class through a common interface.

D) It refers to a class having multiple constructors.

Clear

Only one correct


13) In Python, what is the result of the following code snippet?
a=5
b = 10
if a > 2:
a=a*2
elif b < 15:
b=b*2
else:
a=a+b

https://web.wise.live/v1/student/classes/65373d437b511ca95e6cdb34/tests/654b61ce26f9bd0001c4a10a/start 3/7
14/11/2023, 19:54 web.wise.live/v1/student/classes/65373d437b511ca95e6cdb34/tests/654b61ce26f9bd0001c4a10a/start

print(a, b)

A) 10 10

B) An error will occur

C) 10 5

D) 5 10

Clear

Only one correct


14) In a try-except-finally construct, can you have multiple except blocks for different exception types?

A) Yes, you can have multiple 'except' blocks, each handling a specific exception type.

B) You cannot have an 'except' block in a try-except-finally construct.

C) Yes, you can have multiple 'except' blocks, but they all handle the same exception type.

D) No, you can only have one 'except' block.

Clear

Only one correct


15) What is the purpose of the *args and **kwargs in function definitions in Python?

A) They are used to define a generator function.

B) They are used to access global variables.

C) They are used to pass a variable number of non-keyword and keyword arguments to a function.

D) They are used to specify the function's return type.

Clear

Only one correct


16) What does the 're.findall()' function return when used with a regular expression pattern in Python?

A) A list of all non-overlapping matches of the pattern in a string.

B) The number of matches found.

C) A list of overlapping matches of the pattern in a string.

D) The first occurrence of the pattern in a string.

Clear

Only one correct


17) Which of the following is the correct way to format a string using the % operator in Python?

A) "Hello, %s!" % name

B) "Hello, {0}!".format(name)

https://web.wise.live/v1/student/classes/65373d437b511ca95e6cdb34/tests/654b61ce26f9bd0001c4a10a/start 4/7
14/11/2023, 19:54 web.wise.live/v1/student/classes/65373d437b511ca95e6cdb34/tests/654b61ce26f9bd0001c4a10a/start

C) "Hello, {name}!"

D) "Hello, {}!".format(name)

Clear

Only one correct


18) What is a decorator in Python?

A) A special type of class that inherits from the @ symbol.

B) A Python built-in module for creating custom data structures.

C) A function that takes another function and extends its behavior without explicitly modifying it.

D) A design pattern used for creating complex classes.

Clear

Only one correct


19) What is the primary purpose of the namedtuple class from the collections module in Python?

A) To create named variables.

B) To create sets.

C) To create classes for representing simple objects.

D) To create dictionaries.

Clear

Only one correct


20) What does the math.ceil(x) function in Python do?

A) Returns the integer closest to x, rounding up if necessary.

B) Returns the factorial of x.

C) Returns the sine of x.

D) Returns the floor value of x.

Clear

Only one correct


21) What is the output of the following code in Python?
for i in range(1, 5):
if i == 3:
continue
print(i)

A) 1,2

B) 1,2,3,4

https://web.wise.live/v1/student/classes/65373d437b511ca95e6cdb34/tests/654b61ce26f9bd0001c4a10a/start 5/7
14/11/2023, 19:54 web.wise.live/v1/student/classes/65373d437b511ca95e6cdb34/tests/654b61ce26f9bd0001c4a10a/start

C) 1,2,4

D) 1

Clear

Only one correct


22) Which of the following is not a valid way to import the datetime module in Python?

A) import datetime_module

B) from datetime import datetime

C) import datetime as dt

D) import datetime

Clear

Only one correct


23) In a regular expression pattern, what does the | (pipe) symbol represent?

A) An optional character.

B) A quantifier for matching multiple characters.

C) Alternation, allowing for multiple alternatives.

D) The start of a line.

Clear

Only one correct


24) In Python, which of the following is not a valid variable name?

A) 123variable

B) ThisIsAValidVariableName

C) _myVar

CPP_Test
D) my_variable
26 m 04 s
Clear
Attempted 25 Not attempted 0

Only one correct


25) What is the result of the following code snippet in Python?
a = [1, 2, 3]
b=a
b[0] = 4
print(a)

A) [4, 2, 3]

B) An error will occur.

https://web.wise.live/v1/student/classes/65373d437b511ca95e6cdb34/tests/654b61ce26f9bd0001c4a10a/start 6/7
14/11/2023, 19:54 web.wise.live/v1/student/classes/65373d437b511ca95e6cdb34/tests/654b61ce26f9bd0001c4a10a/start

C) [4, 2, 3, 4]

D) [1, 2, 3]

Clear

Submit Test

https://web.wise.live/v1/student/classes/65373d437b511ca95e6cdb34/tests/654b61ce26f9bd0001c4a10a/start 7/7

You might also like