Which of the following is the correct output from the following program?
Need help with this assignment?Get an original answer from a qualified tutor — from $10/page.
Get it written →Question 1 Which of the following is the correct output from the following program?
sequence = [1, 4, 7, 10, 13]
for i in range(len(sequence)):
if i> 2:
sequence[i] = sequence[i] – sequence[i-2]
print(sequence)
Question 1 options:
[1, 4, 7, 10, 6]
[1, 4, 7, 6, 6]
[1, 4, 6, 6, 6]
[1, 4, 7, 10, 13]
Question 2 Which of the following for loops will compute the sum of all the elements in the array numbers, assuming numbers has already been assigned a collection of numeric values?
sum = 0
for i in range(len(numbers)):
sum = numbers[i]
sum = 0
for i in range(numbers):
sum = numbers[i]
sum = 0
for i in range(len(numbers)):
sum = sum + i
sum = 0
for i in range(len(numbers)):
sum = sum + numbers[i]
Question 3 Which of the following is the correct output from the following sequence of statements?
sequence = [0, 1, 1, 2, 3, 5, 8]
sequence[-3] = 0
print(sequence[5])
5
0
3
It generates an IndexError
Question 4 Which of the following is the correct output from this sequence of statements?
letters = [‘a’, ‘b’, [‘c’, ‘d’, [‘e’, ‘f’]], ‘g’]
print(len(letters[2]))
6
4
3
7
Question 5 Which of the following is the correct output from this sequence of statements?
digits = [‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’]
digits.remove(‘2’)
third = digits.pop(3)
print(digits)
[‘2’, ‘4’, ‘5’, ‘6’]
[‘1’, ‘3’, ‘4’, ‘6’]
[‘1’, ‘2’, ‘5’, ‘6’]
[‘1’, ‘2’, ‘4’, ‘6’]
Question 6 Which of the following is the correct output from this sequence of statements?
array1 = [1, 2, 3]
array2 = [2, 3]
print(array1 + array2 * 2)
[1, 2, 3, 2, 3, 2, 3]
[1, 2, 3]
[1, 2, 3, 2, 3, 1, 2, 3, 2, 3]
[1, 2, 3, 2, 3]
Question 7 Which of the following is the correct output from this sequence of statements?
cubes = [1, 8, 27, 64, 125, 216]
cubes[3:5] = [1, 2]
print(cubes[2:6])
[1, 2, 216]
[8, 27, 1, 2]
[8, 1, 2, 125]
[27, 1, 2, 216]
Question 8 Which of the following programs will output None?
values = [7, 10, 13, 16]
values.extend([1, 4])
values.sort()
print(values)
values = [7, 10, 13, 16]
values.append(1)
values.append(4)
values.sort()
print(values)
values = [7, 10, 13, 16]
values.sort()
values.extend([1, 4])
print(values)
values = [7, 10, 13, 16]
values.append(1)
values.append(4)
print(values.sort())
Question 9 Which of the following is the correct output from this sequence of statements?
numbers = [18, 27, 42, 13, 21, 8, 11]
print(sum(numbers) / len(numbers))
42.0
20.0
7.0
8.0
Question 10 Which of the following is the correct output from this sequence of statements?
numbers = [1, 2, 3]
numbers.append(2)
numbers.sort()
print(numbers)
[1, 2, 3, 2]
[1, 2, 2, 3]
None
[1, 2, 3]
Get a plagiarism-free answer to this question
Send us your instructions and we’ll match you with the best writer in your subject.
- 100% human-written, zero AI
- Turnitin report included
- Confidential — we never share your data
- Free revisions & refunds