
Python Debugging 2
Authored by Murugeswari.k Murugeswari.k
Computers
University
Used 1+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
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)
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.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
Asesmen Diagnostik Sistem Komputer
Quiz
•
10th Grade - University
13 questions
Podsumowanie: binarny, komputer, sieć
Quiz
•
7th Grade - University
10 questions
Quiz Ke 8 alprog if-09
Quiz
•
University
15 questions
Data Mining - Classification Mining
Quiz
•
University
10 questions
Quiz CodeIgniter 4
Quiz
•
University
10 questions
Què has après sobre el web ?
Quiz
•
University
10 questions
Lenguaje Perl
Quiz
•
University
9 questions
CHAPTER 5 ONLINE QUIZ
Quiz
•
University
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade