Ask Question
28 November, 17:41

Copy the countdown function from Section 5.8 of your textbook. def countdown (n) : if n >> countup (-3) - 3 - 2 - 1 Blastoff! Write a Python program that gets a number using keyboard input. (Remember to use input for Python 3 but raw_input for Python 2.) If the number is positive, the program should call countdown. If the number is negative, the program should call countup. Choose for yourself which function to call (countdown or countup) for input of zero. Provide the following. The code of your program. Output for the following input: a positive number, a negative number, and zero. An explanation of your choice for what to call for input of zero.

+3
Answers (1)
  1. 28 November, 18:55
    0
    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)

    number = int (input ("Enter a number: "))

    if number > = 0:

    countdown (number)

    elif number < 0:

    countup (number)

    Outputs:

    Enter a number: 3

    3

    2

    1

    Blastoff!

    Enter a number: - 3

    -3

    -2

    -1

    Blastoff!

    Enter a number: 0

    Blastoff!

    For the input of zero, the countdown function is called.

    Explanation:

    Copy the countdown function

    Create a function called countup that takes one parameter, n. The function counts up from n to 0. It will print the numbers from n to - 1 and when it reaches 0, it will print "Blastoff!".

    Ask the user to enter a number

    Check if the number is greater than or equal to 0. If it is, call the countdown function. Otherwise, call the countup function.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Copy the countdown function from Section 5.8 of your textbook. def countdown (n) : if n >> countup (-3) - 3 - 2 - 1 Blastoff! Write a ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers