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
how many usable host addresses are available for each subnet when 4 bits are borrowed from a class C IP address
jonny [76]

Answer:

The answer is "14".

Explanation:

Let the IP address = 196.45.204.0

When it borrowed 4 bits

\therefore\\\\ subnet = 28

IP=  \frac{196.45.204.0}{28}\\\\ 28 \to 11111111.11111111.11111111.11110000

If the borrowed bits are left out then:

The Number of useable host addresses:

= {(2^4) - 2} \\\\ = 16-2\\\\ =14

3 0
2 years ago
Fryshta is using the Help window in PowerPoint to learn about inserting Smart Shapes into a presentation. She currently has a He
Rainbow [258]

Answer: Pin

Explanation:

Pin button is the button that is used for sticking or saving the ideas from the windows or web on that very place.This feature helps in reviewing or getting the idea back later anytime from the window as per users need. User use this button for saving any food recipe, steps of any process, guidelines etc.

  • According to the question, Fryshta can use pin button from the help window for sticking or pinning the steps of inserting shapes in her presentation.She can have a look at the steps whenever she want.
8 0
3 years ago
Write a program with class name Digits that prompts the user to input a positive integer and then outputs the number reversed an
mr Goodwill [35]

Answer:

Written in Python:

inputnum = int(input("User Input: "))

outputnum = 0

total = 0

while(inputnum>0):

     remainder = inputnum % 10

     outputnum = (outputnum * 10) + remainder

     inputnum = inputnum//10

     total = total + remainder

print("Reverse: "+str(outputnum))

print("Total: "+str(total))

Explanation:

This prompts user for input

inputnum = int(input("User Input: "))

This initializes the reverse number to 0

outputnum = 0

This initializes total to 0; i.e. sum of each digit

total = 0

The following iteration gets the reverse of user input

<em>while(inputnum>0): </em>

<em>      remainder = inputnum % 10 </em>

<em>      outputnum = (outputnum * 10) + remainder </em>

<em>      inputnum = inputnum//10 </em>

<em>      This adds each digit of user input</em>

<em>      total = total + remainder </em>

This prints the reversed number

print("Reverse: "+str(outputnum))

This prints the sum of each digit

print("Total: "+str(total))

7 0
3 years ago
Select the correct answer.
9966 [12]

Answer:

B

Explanation:

Every HTML document must begin with a declaration of what the document is going to be about.

4 0
2 years ago
The TechWorld goes on a fast pace, what do you think would be the solution to the growing amount of data being collected by the
Nuetrik [128]

The solution to the growing amount of data in software applications to have fully sustainable usage for customers is;

  • Development of a sustainable model for the future now requires data storage that is engineered to be lower power requirements, lower cooling requirements, and lower waste production.

<h3>Sustainable data storage and usage</h3>

The objective of Sustainable Data Storage Initiative is to spread awareness of the solutions that can reduce the environmental impact of high waste producing data centers.

The environmental impact of data infrastructure is growing as data workloads increase. Hence, building a sustainable model for the future now requires data storage that is engineered to be lower power requirements, lower cooling requirements, and lower waste production.

Read more on Sustainable data storage and usage;

brainly.com/question/24882256

7 0
2 years ago
Other questions:
  • Why has unicode become the standard way of converting binary to text??
    8·1 answer
  • You've formatted the first paragraph of a document. What button can you use to apply the formatting from the first paragraph to
    9·2 answers
  • *asap* Name one of the similarities between Word and Excel.
    7·1 answer
  • What image format should be used to keep the file size manageable​
    14·1 answer
  • When performing a basic search with Bing, you first type in your search expression and then click a button to begin the search;
    13·1 answer
  • Gabe wants to move text from one document to another document. He should _____.
    9·2 answers
  • A domain name is used to: *
    15·1 answer
  • Lindsey also needs to calcite the commissions earned each month. If the company earns $200,000 or more in a month, the commissio
    5·1 answer
  • What might be some challenges if you’re trying to design a product for someone
    14·2 answers
  • As of 2019, approximately how much of the world population actively access the internet?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!