139k views
2 votes
Print a countdown from n to 1 The function below takes one parameter: an integer (begin). Complete the function so that it prints the numbers starting at begin down to 1, each on a separate line. There are two recommended approaches for this:

(1) use a for loop over a range statement with a negative step value, or

(2) use a while loop, printing and decrementing the value each time.

student.py 1 - def print_countdown(begin): # Implement your function here. Be sure to indent your code block! Restore original file

1 Answer

4 votes

Answer:

Step-by-step explanation:

>>> def print_countdown(begin)

>>> i = begin

>>> while i < 1:

>>> print(i)

>>> i = i - 1

>>>print_countdown(0)

User Sarath Subramanian
by
6.4k points