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]
2 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]2 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
What is a protein called if it loses its shape?
hichkok12 [17]
When a protein is denatured, itloses its function. Examples: A denatured enzyme ceases to function. A denatured antibody no longer can bind its antigen.
7 0
3 years ago
Convert<br> 0.625 to binary
Anastaziya [24]

\huge{ \rm{Question:}}

Convert

0.625 to binary

\huge{ \rm{Answer:}}

Translate 0.625 into a fraction. We all know that 0.5 is ½. We know that the remainder, 0.125, is ⅛. Add them together, and you get ½ + ⅛ = ⅝.

Now, in binary, the positions to the right of the point are , which is ½, ¼, and ⅛ respectively.

⅝ is 5 × ⅛. 5 in binary is 101. So, ⅝ is

= 0.101

8 0
2 years ago
The fastest way to get help is to type a word or two in the search box.
Elanso [62]
The fastest way to get help is to type a word or two in the search box. TRUE.
5 0
3 years ago
Which statement best describes the computers all around us?
Advocard [28]

Answer:

B

Explanation:

we are in a digital generation, where by technology is gradually taking over the world. Almost all business, schools, company, etc make use of computer.

8 0
1 year ago
Set-In-Order includes making changes to the layout of the area.A) TrueB) False
Bogdan [553]

Answer:

A) True

Explanation:

Set-In-Order is part of a 5S system approach of making a workplace to be well arranged so there will be smooth operation of employees and working conditions.

Set-In-Order specifically deals with entities in the workplace apparently labeled after being well arranged in their respective places.

Hence, it is TRUE that Set-In-Order includes making changes to the layout of the area.

7 0
3 years ago
Other questions:
  • To apply the rule of thirds you first? PLZ HURRY AND ANSWER THIS
    5·2 answers
  • In your presentation you added a text box to?
    5·1 answer
  • Maria is comparing her history project's second-place award to her classmate's first-place award. She starts planning how to win
    6·2 answers
  • The final element of an e-mail message should be
    15·1 answer
  • Assume that name and age have been declared suitably for storing names (like "abdullah", "alexandra" and "zoe") and ages respect
    14·1 answer
  • Is your florida learners license number the same as the actual license number?
    14·2 answers
  • Does clicking ads and pop ups like the one shown in this image could expose your computer to malware?
    15·1 answer
  • In cell I8, enter a nested logical function to display Need to Remodel if the apartment is unoccupied (No) AND was last remodele
    9·1 answer
  • drag each type of document to the correct location on the table. Drag each document to its respective category
    7·1 answer
  • The Internet is based on a U.S. government project called ________. Today, the Internet is a collection of networks, tied togeth
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!