Python Debugging 2

Python Debugging 2

University

10 Qs

quiz-placeholder

Similar activities

Java Operators

Java Operators

University

14 Qs

Python introduction

Python introduction

University

15 Qs

PYTHON PROGRAMMING

PYTHON PROGRAMMING

University

10 Qs

Python

Python

1st Grade - University

10 Qs

Java Methods

Java Methods

University

15 Qs

Java Quiz based on array

Java Quiz based on array

University

15 Qs

CodeHS Python

CodeHS Python

9th Grade - Professional Development

15 Qs

PythonProgramming

PythonProgramming

University

15 Qs

Python Debugging 2

Python Debugging 2

Assessment

Quiz

Computers

University

Hard

Created by

Murugeswari.k Murugeswari.k

Used 1+ times

FREE Resource

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

  1. What will be the output of the following program ?

  2. L = list('123456')

  3. L[0] = L[5] = 0

  4. L[3] = L[-2]

    print(L)

[0, ‘2’, ‘3’, ‘4’, ‘5’, 0] 

[‘6’, ‘2’, ‘3’, ‘5’, ‘5’, ‘6’] 

[‘0’, ‘2’, ‘3’, ‘5’, ‘5’, ‘0’]

[0, ‘2’, ‘3’, ‘5’, ‘5’, 0] 

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following program ?

T = 'geeks'

a, b, c, d, e = T

b = c = '*'

T = (a, b, c, d, e)

print(T)

(‘g’, ‘*’, ‘*’, ‘k’, ‘s’) 

(‘g’, ‘e’, ‘e’, ‘k’, ‘s’) 

(‘geeks’, ‘*’, ‘*’) 

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the value of L at the end of execution of the following program?

L = [2e-04, 'a', False, 87]

T = (6.22, 'boy', True, 554)

for i in range(len(L)):

if L[i]:

L[i] = L[i] + T[i]

else:

T[i] = L[i] + T[i]

break

[6.222e-04, ‘aboy’, True, 641] 

[6.2202, ‘aboy’, 1, 641]

TypeError 

[6.2202, ‘aboy’, False, 87] 

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What will be the output of the following program ?

T = (2e-04, True, False, 8, 1.001, True)

val = 0

for x in T:

val += int(x)

print(val)

11

12

11.001199999999999 

Answer explanation

Integer value of 2e-04(0.0002) is 0, True holds a value 1 and False a 0, integer value of 1.001 is 1. Thus total 0 + 1 + 0 + 8 + 1 + 1 = 11.

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What will be the output of the following program ?

L = [3, 1, 2, 4]

T = ('A', 'b', 'c', 'd')

L.sort()

counter = 0

for x in T:

L[counter] += int(x)

counter += 1

break

print(L)

[66, 97, 99, 101] 

[66, 68, 70, 72]

[66, 67, 68, 69]

ValueError

Answer explanation

After sort(L), L will be = [1, 2, 3, 4]. Counter = 0, L[0] i.e. 1, x = ‘A’, but Type Conversion of char ‘A’ to integer will throw error and the value cannot be stored in L[0], thus a ValueError.

6.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

What will be the output of the following program ?

str1 = '{2}, {1} and {0}'.format('a', 'b', 'c')

str2 = '{0}{1}{0}'.format('abra', 'cad')

print(str1, str2)

c, b and a abracad0 

a, b and c abracadabra 

a, b and c abracadcad 

c, b and a abracadabra

Answer explanation

String function format takes a format string and an arbitrary set of positional and keyword arguments. For str1 ‘a’ has index 2, ‘b’ index 1 and ‘c’ index 0. str2 has only two indices 0 and 1. Index 0 is used twice at 1st and 3rd time.

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What will be the output of the following program ?

import string

Line1 = "And Then There Were None"

Line2 = "Famous In Love"

Line3 = "Famous Were The Kol And Klaus"

Line4 = Line1 + Line2 + Line3

print("And" in Line4)

True 2 

True 

False

False 2 

Answer explanation

The “in” operator returns True if the strings contains the substring (ie, And), else returns False. 

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?