Question: Which list will be referenced by the variable number after the execution of the following code? number = range(0, 9, 2) a. [0, 1, 2,
Which list will be referenced by the variable number after the execution of the following code?
number = range(0, 9, 2)
| a. | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] |
| b. | [1, 3, 5, 7, 9] |
| c. | [2, 4, 6, 8] |
| d. | [0, 2, 4, 6, 8] |
2.) What is the format for the while clause in Python?
| a. | while condition |
| b. | while condition : |
| c. | while condition statement |
| d. | while condition : statement |
) What would be the value of the variable list after the execution of the following code?
list = [1, 2, 3, 4]
list[3] = 10
| a. | [1, 2, 3, 10] |
|
| b. | [1, 2, 10, 4] |
|
| c. | [1, 10, 10, 10] |
|
| d. | invalid code |
|
4.) What method or operator can be used to concatenate lists?
| a. | * |
|
| b. | + |
|
| c. | % |
|
| d. | concat |
|
What would be the value of the variable list2 after the execution of the following code?
list1 = [1, 2, 3]
list2 = []
for element in list1
list2.append(element)
list1 = [4, 5, 6]
| a. | [1, 2, 3] |
|
| b. | [4, 5, 6] |
|
| c. | [1, 2, 3, 4, 5, 6] |
|
| d. | invalid code |
|
) What are the values that the variable num contains through the iterations of the following for loop?
for num in range(4)
| a. | 1, 2, 3, 4 |
| b. | 0, 1, 2, 3, 4 |
| c. | 1, 2, 3 |
| d. | 0, 1, 2, 3 |
7.) When a file has been opened using the r mode specifier, which method will return the files contents as a string?
| a. | write |
| b. | input |
| c. | get |
| d. | read |
8.) Which method could be used to convert a numeric value to a string?
| a. | str |
| b. | value |
| c. | num |
| d. | chr |
9.) Which method will return an empty string when it has attempted to read beyond the end of a file?
| a. | read |
|
| b. | getline |
|
| c. | input |
|
| d. | readline |
|
10.) What is the result of the following statement?
x = random.randint(5, 15) * 2
| a. | A random integer from 5 to 15, multiplied by 2, assigned to the variable x |
| b. | A random integer from 5 to 15 assigned to the variable x |
| c. | A random integer from 5 to 15, selected in 2 steps, assigned to the variable x |
| d. | A random integer from 5 to 15, raised to the power of 2, assigned to the variable x |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
