Nucleus Previous Years Solved Sample Placement Papers
-
What is the maximum possible length of an identifier in Python?
A. 79 characters
B. 31 characters
C. 63 characters
D. None of the mentioned Answer: Option D
- Solution: Identifiers in Python can be of any length.
-
What will be the output of the following Python program?
i = 0
while i < 5:
print(i)
i += 1
if i == 3:
break
else:
print(0)
A. Error
B. 0 1 2 0
C. 0 1 2 Answer: Option C
D. None of the mentioned
- Solution: The `else` part of the `while` loop is not executed if the loop is terminated using a `break` statement.
-
What will be the output of the following Python code?
x = 'abcd'
for i in range(len(x)):
print(i)
A. Error
B. 1 2 3 4
C. a b c d
D. 0 1 2 3 Answer: Option D
- Solution: The `range(len(x))` generates values 0 to 3, which are printed by the `print(i)` statement.
-
What are the two main types of functions in Python?
A. System function
B. Custom function
C. Built-in function & User defined function Answer: Option C
D. User function
- Solution: Python functions are divided into built-in functions (e.g., `len()`, `dir()`) and user-defined functions created using the `def` keyword.
-
What will be the output of the following Python program?
def addItem(listParam):
listParam += [1]
mylist = [1, 2, 3, 4]
addItem(mylist)
print(len(mylist))
A. 5 Answer: Option A
B. 8
C. 2
D. 1
- Solution: The `+=` operator appends `[1]` to the existing list. Hence, the length of the list becomes 5.
-
Which of the following is a Python tuple?
A. {1, 2, 3}
B. {}
C. [1, 2, 3]
D. (1, 2, 3) Answer: Option D
- Solution: Tuples are immutable data structures represented with round brackets `( )`.