Ask Question
15 June, 09:06

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. 15 June, 09:49
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers