• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Python Output Type

Question 1

What is the output of the following program : 

Python3
def myfunc(a):
    a = a + 2
        a = a * 2
    return a

print myfunc(2)
  • 8

  • 16

  • Indentation Error

  • Runtime Error

Question 2

What is the output of the expression : 3*1**3
  • 27
  • 9
  • 3
  • 1

Question 3

What is the output of the following program : 

Python3
print \'{0:.2}\'.format(1.0 / 3)
  • 0.333333

  • 0.33

  • 0.333333:-2

  • Error

Question 4

What is the output of the following program : 

Python3
print \'{0:-2%}\'.format(1.0 / 3)
  • 0.33

  • 0.33%

  • 33.33%

  • 33%

Question 5

What is the output of the following program : 

Python3
i = 0
while i < 3: 
	print i 
	i += 1
else: 
	print 0
  • 0 1 2 3 0

  • 0 1 2 0

  • 0 1 2

  • Error

Question 6

What is the output of the following program : python
i = 0
while i < 5:
    print(i)
    i += 1
    if i == 3:
        break
else:
    print(0)
  • 0 1 2 0
  • 0 1 2
  • Error
  • None of the above

Question 7

What is the output of the following program : 

Python3
print \'cd\'.partition(\'cd\')
  • (‘cd’)

  • (”)

  • (‘cd’, ”, ”)

  • (”, ‘cd’, ”)

Question 8

What is the output of the following program : 

Python3
print \'abef\'.partition(\'cd\')
  • (‘abef’)

  • (‘abef’, ‘cd’, ”)

  • (‘abef’, ”, ”)

  • Error

Question 9

What is the output of the following program : 

Python3
print \'abcefd\'.replace(\'cd\', \'12\')
  • ab1ef2

  • abcefd

  • ab1efd

  • ab12ed2

Question 10

What will be displayed by the following code? Python
def f(value, values):
    v = 1
    values[0] = 44
t = 3
v = [1, 2, 3]
f(t, v)
print(t, v[0])
  • 1 1
  • 1 44
  • 3 1
  • 3 44

There are 11 questions to complete.

Last Updated :
Take a part in the ongoing discussion