answers will be coming soon.
You will receive this Python summary on the exam.
1. What is printed by the following?
x=3
y=5
print('{} * {} = {}'.format(x,y,x*y))
print('+'*x + "hello" + '+'*y)
4. What are the values of x and y at the end of the following loop:
x=1
y=0
while y < 20:
y = y+x
x = x+1
Hint: make a table of x,y values as of the start of the loop. Initially (x,y) = (1,0); after one time through (x,y) = (2,1)
6. What is printed by the following? There is one pair of numbers per line.
for i in range(1,5):
for j in
range(0,i):
print(i,j)
What is returned by filter([1, 2, 4, 5, 7, 12, 16, 17])?
10. Below is a while loop. Convert it to a for loop, with an appropriate range().
i=1
sum=0
while i < 6:
sum += i
i += 1