These are sample questions that are very similar to the ones I will ask on the midterm. The midterm will be (slightly) longer.
for i in range(1, 5):
x = (-1) ** i * i
print(i, x)
i = 1
while i <= 10:
print(i)
i += 3
x = int(input("Enter a number: "))I got the following error message:
y = 1 / x
print("The reciprocal of", x, "is", y)
Traceback (most recent call last):What was the specific error? Where did it cause the exception? And what did the user type?
File "x.py", line 2, in <module>
y = 1 / x
ZeroDivisionError: division by zero
|
You can also obtain a PDF version of this. Version of January 28, 2019 at 11:40AM |