Python Programming Basics Practice Test: Python Functional Programming Tools And Mapping Functions — Flashcards | Python | FatSkills

Python Programming Basics Practice Test: Python Functional Programming Tools And Mapping Functions — Flashcards

Fast review mode: answers are shown by default so you can skim quickly. Hide them if you want to self-test.

Python provides several tools and features that support functional programming, including:
Functions: Functions are first-class objects in Python, which means that they can be assigned to variables, passed as arguments to other functions, and returned from functions.
Higher-order functions: Higher-order functions are functions that take other functions as arguments or return functions as results.
Lambda functions: Lambda functions are anonymous functions that can be defined on the fly.
Iterators: Iterators are objects that provide a sequence of values.
Generators: Generators are functions that can be used to create iterators.

These tools and features can be used to implement a variety of functional programming techniques, such as:
Mapping:
Mapping is a technique for applying a function to each element in a sequence.
Filtering: Filtering is a technique for removing elements from a sequence that do not meet a certain criterion.
Reducing: Reducing is a technique for combining the elements of a sequence into a single value.

The map() function takes two arguments: a function and a sequence. It applies the function to each element in the sequence and returns a new sequence containing the results.
The filter() function takes two arguments: a function and a sequence. It returns a new sequence containing the elements of the original sequence for which the function returns True.
The reduce() function takes three arguments: a function, a sequence, and an initial value. It applies the function to each element in the sequence, starting with the initial value, and returns the final result.
 

Related tests:

Python Programming Basics Practice Test: Python Functions

Python Programming Basics Practice Test: Python Built-in Functions

1 of 41 Ready
What will be the output of the following Python code?
f=lambda x:bool(x%2)
print(f(20), f(21))
False True
Shortcuts
Prev Space Show / hide Next
Turn this into a study set.
Sign in with Google to save tricky questions to your reminder list and resume on any device.
Sign in with Google Free • no extra password