Task 3
Task 3
The Python program that implements both the `countdown` and `countup` functions
```python
def countdown(n):
if n <= 0:
print('Blastoff!')
else:
print(n)
countdown(n - 1)
def countup(n):
if n >= 0:
print('Blastoff!')
else:
print(n)
countup(n + 1)
countdown(number)
countup(number)
else:
countdown(number)
```
Output Examples
```
Enter a number: 3
Blastoff!
```
Enter a number: -3
-3
-2
-1
Blastoff!
```
3. For zero:
```
Enter a number: 0
Blastoff!
```
For an input of zero, I chose to call the `countdown` function. This decision is based on the idea
that zero can be treated as a boundary condition. In the context of counting down, reaching zero
is a natural stopping point before the "Blastoff!" message. It provides a clear and consistent
output for users, maintaining the theme of countdowns.
```python
def divide_numbers():
try:
if denominator == 0:
# Perform division
except ValueError as e:
print(f"Error: {e}")
```
```
```
References
Downey, A. B. (2024). Think Python: How to Think Like a Computer Scientist (3rd ed.).
O'Reilly Media.