Nucleus Previous Years Solved Sample Placement Papers
-
Which of the following is true for variable names in Python?
A. Underscore and ampersand are the only two special characters allowed
B. Unlimited length Answer: Option B
C. All private members must have leading and trailing underscores
D. None of the mentioned
- Solution: Variable names in Python can be of unlimited length.
-
What are the values of the following Python expressions?
2**(3**2)
(2**3)**2
2**3**2
A. 512, 64, 512 Answer: Option A
B. 512, 512, 512
C. 64, 512, 64
D. 64, 64, 64
- Solution: - Expression 1: 2**(3**2) = 2**9 = 512. - Expression 2: (2**3)**2 = 8**2 = 64. - Expression 3: 2**3**2 is evaluated as 2**(3**2) due to the right-to-left associativity of the ** operator, resulting in 512.
-
Which of the following is the truncation division operator in Python?
A. |
B. // Answer: Option B
C. /
D. %
- Solution: The // operator performs truncation division by discarding the decimal part of the quotient. For example: 20//3 = 6.
-
What will be the output of the following Python code?
l = [1, 0, 2, 0, 'hello', '', []]
list(filter(bool, l))
A. [1, 0, 2, ‘hello’, ”, []]
B. Error
C. [1, 2, ‘hello’] Answer: Option C
D. [1, 0, 2, 0, ‘hello’, ”, []]
- Solution: The filter function filters out all elements of the list `l` that evaluate to `False` (e.g., 0, empty strings, empty lists). The result is [1, 2, ‘hello’].
-
Which of the following functions is a built-in function in Python?
A. factorial()
B. print() Answer: Option B
C. seed()
D. sqrt()
- Solution: The `print` function is a built-in Python function. Functions like `factorial` and `sqrt` are part of the `math` module, while `seed` is part of the `random` module.
-
Which of the following is the use of id() function in Python?
A. Every object doesn’t have a unique id
B. Id returns the identity of the object Answer: Option B
C. All of the mentioned
D. None of the mentioned
- Solution: The `id()` function returns the unique identity of an object in Python.
-
The following Python program can work with ____ parameters.
def f(x):
def f1(*args, **kwargs):
print("Sanfoundry")
return x(*args, **kwargs)
return f1
A. any number of Answer: Option A
B. 0
C. 1
D. 2
- Solution: The decorator function shown can accept any number of arguments using *args and **kwargs.