Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PYTHON multiple choice questions 1a) Given the following list, what value is at

ID: 3722331 • Letter: P

Question

PYTHON multiple choice questions

1a) Given the following list, what value is at index 5?

1b) Consider the following line of code:

Which one of the following options is a valid line of code for displaying the element at the twenty-second position in the list?

1c) Which statement correctly identifies the error in this code snippet?

DataTypeError: cannot mix integer and floating point numbers

There is no error. The code runs and prints 70.

IndexError: list index out of range

1d) What is the difference between a list and a string?

lists are immutable, but strings can be changed

elements in a list can be accessed using an integer as the index value, but strings can use any numeric data type for the index

1e) Given a list values that contains the first ten prime numbers, which statement prints the index and value of each element in the list?

1f) Consider the following code snippet. What will be stored in the list prices after this code executes?

5

Explanation / Answer

1a)   6
1b)   print(somelist[21])
1c)   IndexError: list index out of range
1d)   lists can hold values of any type, whereas strings are only sequences of characters
1e)   b.
for i in range(10):
   print(i, values[i])
1f)   b. [10.60, 16.43, 14.31, 21.36]