πŸ“Š Python
Q. What is the output of the following code :
Code:
print 9//2
  • (A) 4.5
  • (B) 4.0
  • (C) 4
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (C) 4
πŸ“Š Python
Q. Which function overloads the >> operator?
  • (A) more()
  • (B) gt()
  • (C) ge()
  • (D) rshift()
πŸ’¬ Discuss
βœ… Correct Answer: (D) rshift()
πŸ“Š Python
Q. What is the output of the following program :
Code:
i = 0
while i < 3:
print i
print i+1
  • (A) 0 2 1 3 2 4
  • (B) 0 1 2 3 4 5
  • (C) 0 1 1 2 2 3
  • (D) 1 0 2 4 3 5
πŸ’¬ Discuss
βœ… Correct Answer: (C) 0 1 1 2 2 3
πŸ“Š Python
Q. Which module in Python supports regular expressions?
  • (A) re
  • (B) regex
  • (C) pyregex
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (A) re
πŸ“Š Python
Q. Which of these is not a core data type?
  • (A) Lists
  • (B) Dictionary
  • (C) Tuples
  • (D) Class
πŸ’¬ Discuss
βœ… Correct Answer: (D) Class

Explanation: Class is user defined data type.

πŸ“Š Python
Q. What data type is the object below?
L = [1, 23, β€žhello?, 1]
  • (A) List
  • (B) Dictionary
  • (C) Tuple
  • (D) Array
πŸ’¬ Discuss
βœ… Correct Answer: (A) List

Explanation: List in python starts with [ and ends with ] .
Anything written inside square brackets is list in python.

πŸ“Š Python
Q. What is the output of the following program :
Code:
def myfunc(a):
a = a + 2
a = a * 2
return a
print myfunc(2)
  • (A) 8
  • (B) 16
  • (C) Indentation Error
  • (D) Runtime Error
πŸ’¬ Discuss
βœ… Correct Answer: (C) Indentation Error

Explanation: Python is strict to indentation. Here you might have noticed that the code is not properly indented. So throws an indentation error.

πŸ“Š Python
Q. What is the output of the expression : 3*1**3
  • (A) 27
  • (B) 9
  • (C) 3
  • (D) 1
πŸ’¬ Discuss
βœ… Correct Answer: (C) 3

Explanation: ** is short form of power.
In python ** is precedence over *(multiplication) so first ** will be solved.

= 3*(1**3)
= 3*1
= 3

Hence option C is correct.

πŸ“Š Python
Q. What is the output of the following program :
Code:
print '{0:.2}'.format(1.0 / 3)
  • (A) 0.333333
  • (B) 0.33
  • (C) 0.333333:
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (B) 0.33
πŸ“Š Python
Q. What is the output of the following program :
Code:
print '{0:-2%}'.format(1.0 /
3)
  • (A) 0.33
  • (B) 0.33%
  • (C) 33.33%
  • (D) 33%
πŸ’¬ Discuss
βœ… Correct Answer: (C) 33.33%