Python Programming - Functions
Exercise : Functions - General Questions
- Functions - General Questions
26.
What does the term "anonymous function" refer to?
Answer: Option
Explanation:
An anonymous function in Python refers to a function without a name, often created using the
lambda
keyword.
27.
What will be the output of the following code snippet?
def multiply_by_two(x):
return x * 2
numbers = [1, 2, 3, 4]
squared_numbers = list(map(multiply_by_two, numbers))
print(squared_numbers)
Answer: Option
Explanation:
The
map()
function applies the multiply_by_two
function to each element in the numbers
list.
28.
What is the purpose of the
ord()
function?
Answer: Option
Explanation:
The
ord()
function returns the ASCII value of a character.
29.
What is the purpose of the
sorted()
function?
Answer: Option
Explanation:
The
sorted()
function is used to sort the elements of an iterable, such as a list, in ascending order.
30.
What is the purpose of the
locals()
function?
Answer: Option
Explanation:
The
locals()
function returns a dictionary representing the current local symbol table.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers