What will the following code print Python? list1 = [1,2,3] list2 = [4,5,6] list2
ID: 3931153 • Letter: W
Question
What will the following code print Python?
list1 = [1,2,3]
list2 = [4,5,6]
list2.append (list1)
print(list2)
print(len(list2))
2) What is be the output of the following piece of code?
score = 95
if (score > 90):
print(“Outstanding”)
if (score > 60):
print(“Passed”)
if (score < 70):
print(“Good”)
elif (score > 80):
print(“Excellent”)
3) What is the output of the following code segment?
def main():
x = 2
y = 4.6
print(x, y)
x = change_us(x, y)
print(x, y)
def change_us(a, b):
a = 5
b = 7
print(a, b)
return a
main()
4) What is the output of the following code segment?
l1 = [1, 12, 8, 4, 6, 3, 7, 9, 0, 3, 5, 8, 4, 15, 7, 2]
l2 = [l1[x] for x in range(1, len(l1), 3) ]
print (l2)
Explanation / Answer
Question 1:
Answer:
[4, 5, 6, [1, 2, 3]]
4
Question 2:
Answer:
Outstanding Passed Excellent
Question 3:
Answer:
(2, 4.6) 5, 7) (5, 4.6)
Question 4:
Answer:
[12, 6, 9, 5, 15]
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.