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: ")) y = 1 / x print("The reciprocal of", x, "is", y)I got the following error message:
Traceback (most recent call last): File "x.py", line 2, inWhat was the specific error? Where did it cause the exception? And what did the user type?y = 1 / x ZeroDivisionError: int division or modulo by zero
You can also obtain a PDF version of this. | Version of April 21, 2014 at 12:30PM |