Data Science with Python (Basic) Flashcards
7 cards from real Data Science with Python Certification practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 7 Data Science with Python (Basic) flashcards as text
When is ___ It ____ function is called, in Python
Answer: If ___init___ is customized by user
Python automatically calls __init__ whenever a new instance of a class is created, in order to initialize the object's attributes. It runs on instantiation regardless of whether you defined it yourself or inherited it — traversing a sequence or using a tuple does not trigger it. (Note: the option wording is weak; __init__ fires on every object creation, not only when 'customized'.)
Beyond the formal parameter list in Python, the variadic arguments are contained in
Answer: Tree
When a function uses *args, Python packs the extra positional arguments into a TUPLE — an immutable ordered collection. It is not a stack, dictionary, or tree. ⚠ The stored key ('Tree') is wrong, and the correct value 'tuple' is not among the options, so this question should be rewritten.
In Python, the pass statement is utilized for
Answer: Jump to loop's else block
The pass statement is a null operation: it does nothing and is used as a placeholder where syntax requires a statement but no action is wanted. It does not jump to a loop's else block, recheck the condition, or break out — those are the jobs of normal flow, continue, and break. ⚠ The correct answer is 'Do nothing'; the stored key is wrong.
What does a scikit-learn linear model that estimates sparse coefficients look like?
Answer: Lasso
Explanation: In scikit-learn, a linear model that estimates sparse coefficients is called Lasso. Lasso stands for "Least Absolute Shrinkage and Selection Operator." It is a linear regression model that performs both regularization and feature selection.
When traversing a dictionary in Python, method returns both the key and the value.
Answer: Items
Explanation: To retrieve both the key and value while traversing a dictionary in Python, you can use the items() method. The items() method returns a view object that contains tuples of key-value pairs from the dictionary.
What does the following Python code produce? a, b = 0, 1 while b print(b, end=' '); a, b = b, a+b
Answer: 1 1 2 3 5 8 1 3
This prints the Fibonacci sequence while b < 10. Tracing b: 1, 1, 2, 3, 5, 8, then b becomes 13 which fails b < 10 and stops — so the output is '1 1 2 3 5 8'. ⚠ The stored key ('1 1 2 3 5 8 1 3') is wrong; the correct output is '1 1 2 3 5 8'.
The character used to indicate end of a block in Python, is
Answer: Nothing
Explanation: In Python, the character used to indicate the end of a block is not a specific character like in some other programming languages. Instead, Python uses indentation to define the blocks of code.
How this page was made: written with AI tools and published by Nathan Beja, founder of Practice Test Geeks, who is responsible for its content. We have not yet matched this exam's facts to an official source, so confirm fees, dates and rules with the exam body. Not reviewed by a subject-matter expert. Editorial policy