Introduction to Python for Data Science 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 Introduction to Python for Data Science flashcards as text
Which Python data type is immutable and can be used as a dictionary key?
Answer: tuple
Tuples are immutable sequences and can be used as dictionary keys, unlike lists or sets.
What does the `zip()` function return when passed two lists of unequal length?
Answer: Stops at the length of the shorter list
`zip()` stops producing tuples when the shortest input iterable is exhausted.
Which method removes and returns the last element of a Python list?
Answer: list.pop()
`list.pop()` removes and returns the last element by default, or an element at a given index.
What is the result of `bool([])` in Python?
Answer: False
An empty list is falsy in Python, so `bool([])` evaluates to `False`.
Which of the following correctly creates a dictionary using a dictionary comprehension?
Answer: {x: x**2 for x in range(5)}
Dictionary comprehensions use curly braces with a `key: value` expression followed by a `for` clause.
What will `'data'[::-1]` return in Python?
Answer: 'atad'
The slice `[::-1]` reverses a string by stepping backwards through all characters.
In Python, which keyword is used to define an anonymous function?
Answer: lambda
`lambda` creates small anonymous functions that can have any number of arguments but only one expression.
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