222k views
0 votes
Write (define) a function named count_down_from, that takes a single argument and returns no value. You can safely assume that the argument will always be a positive integer. When this function is called, it should print a count from the argument value down to 0.

Examples: count_down_from(5) will print 5,4,3,2,1,0, count_down_from(3) will print 3,2,1,0, count_down_from(1) will print 1,0,

1 Answer

4 votes

Answer:

Written in Python

def count_down_from(n):

for i in range(n,-1,-1):

print(i)

Step-by-step explanation:

This line defines the function

def count_down_from(n):

This line iterates from n to 0

for i in range(n,-1,-1):

This line prints the countdown

print(i)

User Nabn
by
5.8k points