These are sample questions that are very similar to the ones I will ask on the midterm.
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, in <module> y = 1 / x ZeroDivisionError: int division or modulo by zeroWhat was the specific error? Where did it cause the exception? And what did the user type?
![]() |
ECS 10, Basic Concepts of Computing Fall Quarter 2012 |