What does the following program print?
= 0
m for n in [1.8, 4.2, 1.6, 2.0, 1.88]:
+= int(n)
m print(m)
What is the output of the following program?
= ""
s = 1
i for digit in ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]:
if len(digit) < 5 and i % 2 == 1:
= digit + s
s += 1
i print(s)
range
functionWhat does each of the following range
calls, converted
to a list, evaluate to?
list(range(3))
list(range(4, 7))
list(range(4, 0, -1))
How many elements are in the following ranges?
range(732)
range(6, 88)
range(4, 2)
range(20, 21)
range(0)
What does the following program print?
for x in range(1,4):
print(x + x * x, end=str(x))
Consider the following incomplete program:
=
x =
y for z in range(x, y):
print("WWU")
What pairs of values could be assigned to the variables
x
and y
so that the program prints
WWU
43 times? Select all correct choices.
x: 0 y: 44
x: -21 y: 22
x: -21 y:21
x: -789 y: -746
x: -789 y: 746
x: 1 y: 44
Write a program that prompts the user for a positive integer
\(p\) and uses a for
loop
to print the powers of 2 up to \(2^p\)
(starting at \(p\) == 0).