click below
click below
Normal Size Small Size show me how
quiz 3
COP1000C into comp prog blended 621782
Question | Answer | |
---|---|---|
In Python, what is the result of 2 / 5? | 2 0 0.4 5 | 0.4 |
What is the result of float(int(3.5))? | Question 3 options: 4 3 4.0 3.0 | 3 |
If you want to use the sin function in the math library, as x = sin(3.14), how should you write the import statement? | Question 4 options: import sin import math from math import sin An import statement is not needed. | import math |
If you want to use the sin function in the math library, as x = math.sin(3.14), how should you write the import statement? Question 5 options: | import math | |
Which of the following is a correct Python expression? Question 6 options: X = 2 *A + 2B F = (9/5)*C + 32 F = (9/5)C + 32 X = B**2 - 4A | b | |
The Python numeric type for representing numbers containing fractional values is Question 7 options: int decimal float real | float | |
In Python, what is the result of 2 // 5? Question 8 options: 2 0 0.4 5 | 0.4 | |
The Python numeric type for representing positive or negative whole numbers is: Question 9 options: int float whole | int | |
In Python, what is the result of 2 % 5? Question 10 options: 0.40 5 0 | 0.40 | |
If you want to use the accumulator pattern to add up a sequence of numbers, which of the following would be the correct initialization statement for the accumulator variable? | Question 1 options: total = 1 total = 0 total = -1 total = [] | total = 0 |
What is the output from the following program fragment? for i in range(1,5): print(2 * i,end=" ") Question 2 options: 2 4 6 8 10 1 2 3 4 5 1 2 3 4 2 4 6 8 | ||
What is the output from the following program fragment? for i in range(1,5): print(2 * i,end=" ") Question 2 options: 2 4 6 8 10 1 2 3 4 5 1 2 3 4 2 4 6 8 | 2 4 6 8 | |
Which of the following would be equivalent to the Python expression y = round(x)? Question 3 options: y = math.floor(x) y = int(x) y = int(x + 0.5) y = math.ceil(x) | y = int(x) | |
In Python, what is the result of the expression 2.0 + 5 // 2? Question 4 options: 4 4.0 4.5 none of the above | 4.0 | |
In Python, what is the result of 2 % 5? Question 5 options: 0.40 5 0 | 0 | |
What is the result of float(int(3.5))? Question 9 options: 3 4 4.0 3.0 | 4.0 | |
In Python, what is the result of 2 / 5? Question 10 options: 5 0.4 2 0 | 0 | |
Which of the following statements is true about the Python int and float types? | Both int and float values have a limit on the largest value they can hold. Int values are stored exactly and float values are usually approximations. | Int and float values are both stored exactly. Neither int values nor float values are stored exactly. |