Python Output Type

Last Updated :
Discuss
Comments

Question 1

What does *args collect in a Python function?

  • A

    Extra keyword arguments

  • B

    Default arguments

  • C

    Return values

  • D

    Extra positional arguments

Question 2

What is the output of the expression : 3*1**3

  • A

    27

  • B

    9

  • C

    3

  • D

    1

Question 3

What is the output of the following program : 

Python
print('{0:.2}'.format(1.0 / 3))
  • A

    0.333333

  • B

    0.33

  • C

    0.333333:-2

  • D

    Error

Question 4

What is the output of the following program : 

Python
print ('{0:-2%}'.format(1.0 / 3))
  • A

    0.33

  • B

    0.33%

  • C

    33.33%

  • D

    33%

Question 5

What is the output of the following program : 

Python
i = 0
while i < 3: 
	print(i,end=' ') 
	i += 1
else: 
	print(0)
  • A

    0 1 2 3 0

  • B

    0 1 2 0

  • C

    0 1 2

  • D

    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)
  • A

    0 1 2 0

  • B

    0 1 2

  • C

    Error

  • D

    None of the above

Question 7

What is the output of the following program : 

Python
print('cd'.partition('cd'))
  • A

    (‘cd’)

  • B

    (”)

  • C

    (‘cd’, ”, ”)

  • D

    (”, ‘cd’, ”)

Question 8

What is the output of the following program : 

Python
print('abef'.partition('cd'))
  • A

    (‘abef’)

  • B

    (‘abef’, ‘cd’, ”)

  • C

    (‘abef’, ”, ”)

  • D

    Error

Question 9

What is the output of the following program : 

Python
print('abcefd'.replace('cd', '12'))
  • A

    ab1ef2

  • B

    abcefd

  • C

    ab1efd

  • D

    ab12ed2

Question 10

What will be displayed by the following code?

Python
def f(value, values):
    v = 1
    values[0] = 44
a = 3
v = [1, 2, 3]
f(a, v)
print(a, v[0])
  • A

    1 1

  • B

    1 44

  • C

    3 1

  • D

    3 44

There are 11 questions to complete.

Take a part in the ongoing discussion