Learn with Yasir

Share Your Feedback

Python Built-in Functions MCQs – Multiple Choice Questions for Practice and Learning

Test your understanding of Python built-in functions with these multiple choice questions. Practice using functions like map(), filter(), len(), and more with beginner-friendly MCQs and detailed answers. Ideal for students and Python learners preparing for exams or interviews.

Topic: built-in-functions


📝 Multiple Choice Questions

🟢 Beginner

Q1. What does the `map()` function return in Python 3?

  • 🟢 A. list
  • 🔵 B. tuple
  • 🟠 C. iterator
  • 🔴 D. dict
Answer

iterator

`map()` in Python 3 returns a map object which is an iterator.


Q2. What does the `filter()` function return in Python 3?

  • 🟢 A. list
  • 🔵 B. iterator
  • 🟠 C. set
  • 🔴 D. tuple
Answer

iterator

`filter()` returns a filter object which is an iterator.


Q3. What does `list(zip([1,2], [3,4]))` return?

  • 🟢 A. [(1,3), (2,4)]
  • 🔵 B. [(1,2), (3,4)]
  • 🟠 C. [1,2,3,4]
  • 🔴 D. {1:3, 2:4}
Answer

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

`zip()` pairs items from both lists by index into tuples.


Q4. What is the type of object returned by `map()` in Python 3?

  • 🟢 A. list
  • 🔵 B. map
  • 🟠 C. iterator
  • 🔴 D. tuple
Answer

map

The object is of type `map`, which is an iterator."


Q5. What does `list(zip('abc','123'))` return?

  • 🟢 A. [('abc','123')]
  • 🔵 B. [('a','1'), ('b','2'), ('c','3')]
  • 🟠 C. [('a','b','c'), ('1','2','3')]
  • 🔴 D. [('abc1'), ('abc2'), ('abc3')]
Answer

[('a','1'), ('b','2'), ('c','3')]

Each character of the strings is paired by index."


Q6. What does `list(map(int, ['1','2','3']))` return?

  • 🟢 A. ['1','2','3']
  • 🔵 B. [1,2,3]
  • 🟠 C. [(1),(2),(3)]
  • 🔴 D. Error
Answer

[1,2,3]

The `int` constructor is applied to each string in the list."


Q7. What does the built-in function `len()` return when used on a string?

  • 🟢 A. The number of characters in the string
  • 🔵 B. The number of unique characters
  • 🟠 C. The ASCII value of the first character
  • 🔴 D. The last character of the string
Answer

The number of characters in the string

`len()` returns the total count of characters in the string.


Q8. What is the return type of the `type()` function in Python?

  • 🟢 A. str
  • 🔵 B. int
  • 🟠 C. type
  • 🔴 D. object
Answer

type

`type()` returns the type of the given object, which itself is an instance of `type`.


Q9. Which built-in function converts an object to its string representation?

  • 🟢 A. str()
  • 🔵 B. repr()
  • 🟠 C. ascii()
  • 🔴 D. format()
Answer

str()

`str()` returns a readable string version of an object, often more user-friendly than `repr()`.


Q10. What does the `sorted()` function return?

  • 🟢 A. tuple
  • 🔵 B. list
  • 🟠 C. iterator
  • 🔴 D. dict
Answer

list

`sorted()` always returns a new list containing the sorted elements.


Q11. What does the `any()` function return when all elements of an iterable are `False`?

  • 🟢 A. True
  • 🔵 B. False
  • 🟠 C. None
  • 🔴 D. Error
Answer

False

`any()` returns `True` if at least one element is truthy; otherwise, it returns `False`.


Q12. Which built-in function returns the Unicode code point of a character?

  • 🟢 A. ord()
  • 🔵 B. chr()
  • 🟠 C. ascii()
  • 🔴 D. bytes()
Answer

ord()

`ord('A')` returns `65`, the Unicode code point for 'A'.


Q13. Which function can be used to find the smallest item in an iterable?

  • 🟢 A. max()
  • 🔵 B. min()
  • 🟠 C. sorted()
  • 🔴 D. filter()
Answer

min()

`min()` returns the smallest element from the iterable.


Q14. Which built-in function converts an integer to binary string?

  • 🟢 A. oct()
  • 🔵 B. bin()
  • 🟠 C. hex()
  • 🔴 D. format()
Answer

bin()

`bin(5)` returns `'0b101'`.


🟡 Intermediate

Q1. Which of the following correctly applies `map()` to square a list of numbers `[1, 2, 3]`?

  • 🟢 A. map(lambda x: x**2, [1,2,3])
  • 🔵 B. map(x**2, [1,2,3])
  • 🟠 C. map([1,2,3], lambda x: x**2)
  • 🔴 D. map(lambda: x**2, [1,2,3])
Answer

map(lambda x: x**2, [1,2,3])

The correct syntax is `map(function, iterable)`; here the function is `lambda x: x**2`.


Q2. Which of the following keeps only even numbers from a list using `filter()`?

  • 🟢 A. filter(lambda x: x%2==0, [1,2,3,4])
  • 🔵 B. filter(x%2==0, [1,2,3,4])
  • 🟠 C. filter([1,2,3,4], lambda x: x%2==0)
  • 🔴 D. filter(lambda: x%2==0, [1,2,3,4])
Answer

filter(lambda x: x%2==0, [1,2,3,4])

The lambda returns `True` for even numbers; `filter()` keeps only those values."


Q3. Which of the following correctly transposes a matrix using `zip()`?

  • 🟢 A. list(zip(matrix))
  • 🔵 B. list(zip(*matrix))
  • 🟠 C. zip(matrix)
  • 🔴 D. zip(matrix, matrix)
Answer

list(zip(*matrix))

Unpacking with `*` allows `zip()` to transpose rows into columns."


Q4. Which function can be used with `filter()` to remove all falsy values from a list?

  • 🟢 A. bool
  • 🔵 B. int
  • 🟠 C. str
  • 🔴 D. list
Answer

bool

`filter(bool, iterable)` keeps only truthy values.


Q5. Which of these expressions returns `[(1,4), (2,5)]`?

  • 🟢 A. list(zip([1,2,3], [4,5]))
  • 🔵 B. list(zip([1,2], [4,5,6]))
  • 🟠 C. list(zip([1,2,3], [4,5,6]))
  • 🔴 D. list(zip([1,2], [4,5]))
Answer

list(zip([1,2,3], [4,5]))

`zip()` stops at the shortest iterable, here `[4,5]`.


Q6. Which of these functions can be combined with `map()` to apply multiple functions sequentially?

  • 🟢 A. lambda
  • 🔵 B. zip
  • 🟠 C. filter
  • 🔴 D. reduce
Answer

lambda

A lambda function can wrap multiple function calls and be passed to `map()`."


Q7. Which of the following correctly filters words with length greater than 3?

  • 🟢 A. filter(lambda w: len(w)>3, ['a','word','python'])
  • 🔵 B. filter(len(w)>3, ['a','word','python'])
  • 🟠 C. filter(['a','word','python'], lambda w: len(w)>3)
  • 🔴 D. filter(lambda: len(w)>3, ['a','word','python'])
Answer

filter(lambda w: len(w)>3, ['a','word','python'])

The lambda correctly checks length and `filter()` applies it to each element."


Q8. Which statement best describes the relationship between `map()` and `filter()`?

  • 🟢 A. Both transform data
  • 🔵 B. map() transforms, filter() selects
  • 🟠 C. filter() transforms, map() selects
  • 🔴 D. Both select data
Answer

map() transforms, filter() selects

`map()` applies a function to every element, while `filter()` only keeps those that satisfy a condition.


Q9. What is the output of `list(filter(lambda x: x>5, range(10)))`?

  • 🟢 A. [5,6,7,8,9]
  • 🔵 B. [6,7,8,9]
  • 🟠 C. [10]
  • 🔴 D. Error
Answer

[6,7,8,9]

The filter keeps only numbers greater than 5 from the range 0–9."


Q10. Which built-in function can be used to get the largest item from an iterable?

  • 🟢 A. min()
  • 🔵 B. max()
  • 🟠 C. sum()
  • 🔴 D. sorted()
Answer

max()

`max()` returns the largest item from an iterable based on natural ordering or a provided key.


Q11. Which function is used to convert a string into a list of its characters?

  • 🟢 A. list()
  • 🔵 B. tuple()
  • 🟠 C. set()
  • 🔴 D. str()
Answer

list()

`list('abc')` results in `['a', 'b', 'c']`.


Q12. Which function returns the absolute value of a number?

  • 🟢 A. round()
  • 🔵 B. abs()
  • 🟠 C. pow()
  • 🔴 D. math.fabs()
Answer

abs()

`abs()` returns the absolute value of integers, floats, or complex numbers.


Q13. Which built-in function combines elements from multiple iterables into tuples?

  • 🟢 A. map()
  • 🔵 B. zip()
  • 🟠 C. filter()
  • 🔴 D. reduce()
Answer

zip()

`zip()` pairs items from multiple iterables into tuples until the shortest iterable is exhausted.


Q14. Which built-in function applies a function to all items in an iterable and returns an iterator?

  • 🟢 A. filter()
  • 🔵 B. map()
  • 🟠 C. reduce()
  • 🔴 D. zip()
Answer

map()

`map()` applies the given function to every item in the iterable and returns an iterator.


Q15. What does the `enumerate()` function return?

  • 🟢 A. list of tuples
  • 🔵 B. iterator of tuples
  • 🟠 C. set of tuples
  • 🔴 D. dict of tuples
Answer

iterator of tuples

`enumerate()` returns an iterator of `(index, element)` tuples.


Q16. Which function is used to check if an object is an instance of a class?

  • 🟢 A. issubclass()
  • 🔵 B. type()
  • 🟠 C. isinstance()
  • 🔴 D. callable()
Answer

isinstance()

`isinstance(obj, Class)` checks whether `obj` is an instance of `Class` or its subclasses.


Q17. Which built-in function returns the sum of all elements in an iterable?

  • 🟢 A. reduce()
  • 🔵 B. sum()
  • 🟠 C. map()
  • 🔴 D. all()
Answer

sum()

`sum()` returns the arithmetic sum of all numeric elements in an iterable.


🔴 Advanced

Q1. What happens if `map()` is used with multiple iterables of different lengths?

  • 🟢 A. Raises an error
  • 🔵 B. Stops at the longest iterable
  • 🟠 C. Stops at the shortest iterable
  • 🔴 D. Fills missing values with None
Answer

Stops at the shortest iterable

`map()` stops when the shortest iterable is exhausted.


Q2. What is the output of `list(filter(None, [0, 1, 2, '', 'hello']))`?

  • 🟢 A. [0, 1, 2, '', 'hello']
  • 🔵 B. [1, 2, 'hello']
  • 🟠 C. ['', 'hello']
  • 🔴 D. [0, '', 'hello']
Answer

[1, 2, 'hello']

`filter(None, iterable)` removes all falsy values like `0` and `''`.


Q3. What is the result of `list(map(str.upper, ['a','b']))`?

  • 🟢 A. ['a','b']
  • 🔵 B. ['A','B']
  • 🟠 C. ['upper(a)', 'upper(b)']
  • 🔴 D. ['a.upper()', 'b.upper()']
Answer

['A','B']

`map(str.upper, iterable)` applies `str.upper` method to each string.


Q4. What is the output of `list(map(lambda x,y: x+y, [1,2,3], [4,5,6,7]))`?

  • 🟢 A. [5,7,9,7]
  • 🔵 B. [5,7,9]
  • 🟠 C. [1,2,3,4,5,6,7]
  • 🔴 D. Error
Answer

[5,7,9]

`map()` stops at the shortest iterable, producing three results.


Q5. Which of the following statements about `zip()` is true?

  • 🟢 A. It always returns a list
  • 🔵 B. It returns an iterator of tuples
  • 🟠 C. It fills shorter iterables with None
  • 🔴 D. It can only combine two iterables
Answer

It returns an iterator of tuples

`zip()` produces an iterator of tuples and works with any number of iterables.


Q6. What does the `zip()` function return in Python 3?

  • 🟢 A. list
  • 🔵 B. tuple
  • 🟠 C. iterator
  • 🔴 D. dict
Answer

iterator

In Python 3, `zip()` returns an iterator of tuples, unlike Python 2 which returned a list.


Q7. Which function can be used to dynamically execute a string as Python code?

  • 🟢 A. eval()
  • 🔵 B. exec()
  • 🟠 C. compile()
  • 🔴 D. globals()
Answer

exec()

`exec()` executes dynamic Python code, while `eval()` only evaluates expressions.


Q8. Which function can be used to create an iterable of numbers, but is not itself a built-in function?

  • 🟢 A. range()
  • 🔵 B. xrange()
  • 🟠 C. enumerate()
  • 🔴 D. count()
Answer

xrange()

`xrange()` was available in Python 2 but not in Python 3; `range()` in Python 3 behaves like `xrange()`.


Q9. Which built-in function returns the memory address of an object?

  • 🟢 A. id()
  • 🔵 B. hash()
  • 🟠 C. repr()
  • 🔴 D. globals()
Answer

id()

`id()` returns the unique identity of an object, which is its memory address in CPython.


Explore More Topics

📘 Learn Python

Tutorials, Roadmaps, Bootcamps & Visualization Projects

Python Fundamentals

Flow Control Statements


Python Functions


Fundamentals more ...




🧠 Python Advanced

Object-Oriented Programming in Python (OOP)

More...

🧠 Modules