Python Programming - Tricky Questions
Exercise : Tricky Questions - General Questions
- Tricky Questions - General Questions
21.
What is the purpose of the
is
keyword in Python?
Answer: Option
Explanation:
The
is
keyword checks if two objects refer to the same memory location.
22.
What is the output of the following Python code?
def some_function(x, y, z):
return x + y ** z
result = some_function(x=1, y=2, z=3)
print(result)
Answer: Option
Explanation:
The exponent has higher precedence than addition, so the result is 1 + (2 ** 3) = 9.
23.
What is the output of the following Python code?
x = 5
y = 2
result = x / y
print(result)
Answer: Option
Explanation:
Division (/) in Python 3 returns a floating-point result.
24.
What will be the output of the following Python code?
string1 = "Python"
string2 = "Python"
result = string1 is string2
print(result)
Answer: Option
Explanation:
String interning in Python makes identical string literals refer to the same memory location.
25.
What will be the output of the following Python code?
def func(x):
x += 1
return x
x = 5
result = func(x)
print(x, result)
Answer: Option
Explanation:
The function modifies its local copy of
x
, and the global x
remains unchanged.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers