What will the following code print Python list1 123 list2
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)
Solution
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]
![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 f 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 f](/WebImages/14/what-will-the-following-code-print-python-list1-123-list2-1019023-1761526838-0.webp)
![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 f 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 f](/WebImages/14/what-will-the-following-code-print-python-list1-123-list2-1019023-1761526838-1.webp)