1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
maks197457 [2]
3 years ago
8

Copy the countdown function from Section 5.8 of your textbook. def countdown(n): if n <= 0: print('Blastoff!') else: print(n)

countdown(n-1) Write a new recursive function countup that expects a negative argument and counts "up" from that number. Output from running the function should look something like this: >>> 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.
Computers and Technology
1 answer:
Lapatulllka [165]3 years ago
4 0

Answer:

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)

<u>Outputs:</u>

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.

You might be interested in
Que problema se puede usar con el uso de las TIC ?​
raketka [301]
We do not speak English in this please translate in Google because we do not know Spanish
8 0
3 years ago
List the actual network numbers for each of these subnets. (If the list is longer than 16, simply list the first 3 and final 3 "
Andre45 [30]
69 is the answer because I know or it could be 430
3 0
3 years ago
Which structure is the arrow pointing to?<br><br> What is the function of this organelle?
Lapatulllka [165]

Answer:

The arrow is pointing to the nucleus. The function of a nucleus is that is stores the DNA of a cell. It also regulate and control the activities that go on in the cell like groth, and metabolism.

5 0
3 years ago
Leo needs to consolidate data in multiple worksheets by performing a calculation across all worksheets on the same cells.
wolverine [178]
A do you think is the answer
4 0
3 years ago
Read 2 more answers
The internal movement of atoms in a substance creates
Leona [35]
Thermal Energy I think would be the answer
6 0
4 years ago
Other questions:
  • Which of the following are important for protecting computing devices and systems? Physical safeguards like a secure space prote
    7·1 answer
  • Which Tire would you use to explain a set of phones in an HTML document?
    12·1 answer
  • Your project must satisfy the following requirements:
    7·1 answer
  • Define the missing method. licenseNum is created as: (100000 * customID) + licenseYear. Sample output: Dog license: 77702014
    14·1 answer
  • The faster the clock speed, the more of these the processor can execute per second. what are they?
    15·2 answers
  • ASAP PLZ!!!!!! Select the correct answer from each drop-down menu. Complete the sentences related to the types of sample data. I
    7·1 answer
  • WILL GIVE BRAINLIEST
    15·1 answer
  • The ____ contains app buttons that allow you to quickly run the File Explorer or Microsoft Edge apps.
    12·1 answer
  • After you configure backup settings using the backup plugin, backup jobs will run automatically and start taking backups at the
    13·1 answer
  • Which of the following identifies the most appropriate courses to take in high school for someone interested in becoming a mecha
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!