
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
What will be the output of the following program ?
L = list('123456')
L[0] = L[5] = 0
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
Similar Resources on Wayground
10 questions
PYTHON_CHAPTER 8

Quiz
•
University
11 questions
Python If statement

Quiz
•
University
15 questions
ASK F2 -KOD ARAHAN (PYTHON)

Quiz
•
1st Grade - University
10 questions
Java Control Flow statements

Quiz
•
University
10 questions
Python - Functions

Quiz
•
University
13 questions
Python Module 1

Quiz
•
University - Professi...
15 questions
CodeHS - Intro to Python - Conditionals Quiz

Quiz
•
9th Grade - Professio...
9 questions
IPC144 SLG -- Week2

Quiz
•
University
Popular Resources on Wayground
50 questions
Trivia 7/25

Quiz
•
12th Grade
11 questions
Standard Response Protocol

Quiz
•
6th - 8th Grade
11 questions
Negative Exponents

Quiz
•
7th - 8th Grade
12 questions
Exponent Expressions

Quiz
•
6th Grade
4 questions
Exit Ticket 7/29

Quiz
•
8th Grade
20 questions
Subject-Verb Agreement

Quiz
•
9th Grade
20 questions
One Step Equations All Operations

Quiz
•
6th - 7th Grade
18 questions
"A Quilt of a Country"

Quiz
•
9th Grade