Python - MCQ

Multiple Choice Questions


Share with a Friend

 

Python - Multiple Choice Questions (MCQ) - Basics of Python - Set 5

21. What is the output of the following code?

var1 = 1
var2 = 2
var3 = "3"

print(var + var2 + var3)
A). 6
B). 33
C). 123
D). Error. Mixing operators between numbers and strings are not supported
View Answer
Correct: D



22. What is the output of the following code?

valueOne = 5 ** 2
valueTwo = 5 ** 3

print(valueOne)
print(valueTwo)
A). 10
      15
B). 25
      125
C). Error: invalid syntax
View Answer
Correct: B


23. What is the output of the following code?

var = "James" * 2  * 3
print(var)
A). JamesJamesJamesJamesJamesJames
B). JamesJamesJamesJamesJames
C). Error: invalid syntax
View Answer
Correct: A



24. What is the output of the following code?

var= "James Bond"
print(var[2::-1])
A). Jam
B). dno
C). maJ
D). dnoB semaJ
View Answer
Correct: C


25. What is the output of the following code?

def calculate (num1, num2=4):
  res = num1 * num2
  print(res)

calculate(5, 6)
A). 20
B). The program executed with errors
C). 30
View Answer
Correct: C



 
 
 
   
   
   
UltraInfo Technologies
ITDeveloper