Answer to Question #195525 in Python for desmond

Question #195525

1. Design a recursive function that accepts an integer argument, n, and prints every second number from n down to a minimum of 0. Assume that n is always a positive integer.


1
Expert's answer
2021-05-19T11:57:56-0400
import time

def printNumberDown(n):
    if n!=-1:
        print(n)
        time.sleep(1)
        printNumberDown(n-1)
    
def main():
    n=int(input("Enter n: "))
    printNumberDown(n)


main()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS