Python Programming - Functions
Exercise : Functions - General Questions
- Functions - General Questions
6.
What is the purpose of the
global
keyword inside a function?Answer: Option
Explanation:
The
global
keyword is used to indicate that a local variable should be treated as a global variable.
7.
What will be the result of the following code snippet?
x = 10
def multiply_by_two():
global x
x *= 2
multiply_by_two()
print(x)
Answer: Option
Explanation:
The
global
keyword inside the function indicates that the variable x
should be treated as a global variable, and its value is multiplied by 2.
8.
How do you pass a variable number of arguments to a function?
Answer: Option
Explanation:
The
*args
syntax allows a function to accept a variable number of positional arguments.
9.
What is the purpose of the
lambda
keyword?
Answer: Option
Explanation:
The
lambda
keyword is used to create anonymous functions, also known as lambda functions.
10.
What does the term "recursion" refer to in the context of programming?
Answer: Option
Explanation:
Recursion is a programming concept where a function calls itself in its own definition.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers