What will be the output of the following program ?
L = list('123456')
L[0] = L[5] = 0
L[3] = L[-2]
print(L)

Python Debugging 2

Quiz
•
Computers
•
University
•
Hard
Murugeswari.k Murugeswari.k
Used 1+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
[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
Similar Resources on Quizizz
10 questions
04 - Python - Lists

Quiz
•
University - Professi...
10 questions
C - Pointers

Quiz
•
University
15 questions
Exam 1 Practice

Quiz
•
University
15 questions
Python Basics

Quiz
•
University
10 questions
exception

Quiz
•
University
14 questions
Python Revision

Quiz
•
University
15 questions
Python End of Topic Quiz

Quiz
•
8th Grade - University
10 questions
Python debugging

Quiz
•
University
Popular Resources on Quizizz
15 questions
Character Analysis

Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
10 questions
American Flag

Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension

Quiz
•
5th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25

Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers

Quiz
•
6th - 8th Grade