What is the output of the following code ?
p = [[x, x / 2, x * 2] for x in range(-2, 5, 2) if x > 0]
print(p)
What is the output of the following code ?
students1 = ['John', 'Doe', 'Bob', 'Foo']
students2 = students1
students3 = students1[:]
students2[0] = 'Alec'
students3[1] = 'Steve'
total = 0
for ls in (students1, students2, students3):
if ls[0] == 'Alec':
total += 1
if ls[1] == 'Steve':
total += 5
print(total)
What is the output of the following code ?
>>> s = [23, 56, 18 ,32]
>>> s.reverse()
>>> s
What is the output of the following code ?
>>> s1 = ['python2' , 'python3', 'java8', 'perl5', 'java9']
>>> s2 = [i.upper() for i in s1 if i[0] == 'p' ]
>>> s2
What is the output of the following code ?
>>> s1 = [34, 56, 71]
>>> s2 = s1
>>> s2[2] = 21
>>> s1
What is the output of the following code ?
>>> s1 = [57, 18 , 3, 23]
>>> s2 = s1[:]
>>> s2[2] = 67
>>> s1
What is the output of the following code ?
>>> s1 = [92 , 57, [82, 75]]
>>> s2 = s1[:]
>>> s2[2][1] = 23
>>> s1
What is the output of the following code ?
>>> s = ['apple', 'orange', 'banana']
>>> s.sort(key=len)
>>> s
What is the output of the following code ?
>>> s = [45, 67, 2]
>>> p = s.copy()
>>> p == s, p is s
What is the output of the following code ?
s = list((23,) * 4)
print((2) * 4)
print(s)