Q. What will be the output of the following code?

Code:
print(10 % 3)
  • (A) 3
  • (B) 1
  • (C) 0
  • (D) 10
πŸ’¬ Discuss
βœ… Correct Answer: (B) 1
Explanation: The % operator returns the remainder. 10 % 3 = 1.

Q. Which of these is not a core data type in Python?

  • (A) List
  • (B) Tuple
  • (C) Class
  • (D) Dictionary
πŸ’¬ Discuss
βœ… Correct Answer: (C) Class
Explanation: Class is a user-defined structure, not a core built-in data type like list, tuple, or dict.

Q. What is the output of the following code?

Code:
print('python'.upper())
  • (A) PYTHON
  • (B) python
  • (C) Python
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (A) PYTHON
Explanation: The upper() method converts all characters in the string to uppercase.

Q. What is the output of the following code?

Code:
x = [1, 2, 3]
print(x[-1])
  • (A) 1
  • (B) 2
  • (C) 3
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (C) 3
Explanation: Negative indexing starts from the end. x[-1] refers to the last element, which is 3.

Q. What is the output of the following code?

Code:
x = (1, 2, 3)
x[0] = 5
  • (A) (5, 2, 3)
  • (B) Error
  • (C) (1, 2, 3)
  • (D) (1, 5, 3)
πŸ’¬ Discuss
βœ… Correct Answer: (B) Error
Explanation: Tuples are immutable, so their elements cannot be modified.

Q. What is the output of the following code?

Code:
x = [1, 2, 3]
print(x * 2)
  • (A) [1, 2, 3, 1, 2, 3]
  • (B) [2, 4, 6]
  • (C) Error
  • (D) [1, 2, 3, 2]
πŸ’¬ Discuss
βœ… Correct Answer: (A) [1, 2, 3, 1, 2, 3]
Explanation: Multiplying a list replicates its elements. So [1,2,3] * 2 creates [1,2,3,1,2,3].

Q. Which of the following is a Python reserved keyword?

  • (A) switch
  • (B) goto
  • (C) lambda
  • (D) function
πŸ’¬ Discuss
βœ… Correct Answer: (C) lambda
Explanation: Python does not have switch or goto. 'lambda' is a reserved keyword for anonymous functions.

Q. What is the output of the following code?

Code:
x = 'abcd'
print(x[::-1])
  • (A) abcd
  • (B) dcba
  • (C) bcda
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (B) dcba
Explanation: The slice [::-1] reverses a string.

Q. Which of the following functions converts a string to lowercase?

  • (A) lower()
  • (B) toLower()
  • (C) downcase()
  • (D) caseLower()
πŸ’¬ Discuss
βœ… Correct Answer: (A) lower()
Explanation: The lower() method converts all characters of a string to lowercase.

Q. What will be the output of the following code?

Code:
print(type([1,2,3]))
  • (A) <class 'list'>
  • (B) <class 'tuple'>
  • (C) <class 'set'>
  • (D) <class 'dict'>
πŸ’¬ Discuss
βœ… Correct Answer: (A) <class 'list'>
Explanation: Square brackets [] create a list in Python.