Py4e: Chapter 10- Questions and Answers|
100% Verified
Which of the following tuples is greater than x in the following Python sequence?
x = (5, 1, 3)
if ??? > x :
... (6, 0, 0)
What does the following Python code accomplish, assuming the c is a non-empty dictionary?
tmp = list()
for k, v in c.items() :
tmp.append( (v, k) ) It creates a list of tuples where each tuple is a value, key pair
If the variable data is a Python list, how do we sort it in reverse order?
data.sort(reverse=True)
Using the following tuple, how would you print 'Wed'?
days = ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun') print(days[2])
In the following Python loop, why are there two iteration variables (k and v)?
c = {'a':10, 'b':1, 'c':22}
for k, v in c.items() :
100% Verified
Which of the following tuples is greater than x in the following Python sequence?
x = (5, 1, 3)
if ??? > x :
... (6, 0, 0)
What does the following Python code accomplish, assuming the c is a non-empty dictionary?
tmp = list()
for k, v in c.items() :
tmp.append( (v, k) ) It creates a list of tuples where each tuple is a value, key pair
If the variable data is a Python list, how do we sort it in reverse order?
data.sort(reverse=True)
Using the following tuple, how would you print 'Wed'?
days = ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun') print(days[2])
In the following Python loop, why are there two iteration variables (k and v)?
c = {'a':10, 'b':1, 'c':22}
for k, v in c.items() :