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
Suppose that we time three functions in Python: linear searching, binary searching, and sorting. We determine their running time
Igoryamba

Answer:

134

Explanation:

because 6.00×10-9 =51 and 1.80×10-8=10 and 8.00×10-7=73 by adding them it will give the answer out by the figuer 134

6 0
3 years ago
What is the equivalent of film speed in digital cameras?
elena55 [62]
The equivalent of film speed in a digital camera is going to be sensitivity. This will make the correct answer B. 
3 0
4 years ago
Read 2 more answers
What is an effective way to display calculations in a Word document
DanielleElmas [232]
On the main Ribbon, click on Insert tab, in the Symbols Group click the arrow under Equations, and then Insert new equation.
5 0
3 years ago
Read 2 more answers
A5.3 1012 kg satellite is 1,800 m from another satellite that has a mass of 3.5 x 108 kg. What is the gravitational
SIZIF [17.4K]

Answer:

F = 3.82 * 10^4N

Explanation:

Given

Mass of satellite 1 = 5.3 * 10¹²kg

Mass of satellite 2 = 3.5 * 10⁸kg

Distance between them = 1,800 m

Required

Gravitational Force between them.

The gravitational force between them is calculated as thus;

F = \frac{Gm_1m_2}{r^2}

Where G = Gravitational Constant

G = 6.67408 * 10^{-11} Nm^2/kg^2

m_1 = 5.3 * 10^{12}kg

m_2 = 3.5 * 10^8kg

r = 1800m

Substituting these values in the above formula;

F = \frac{Gm_1m_2}{r^2} becomes

F = \frac{6.67408 * 10^{-11} * 5.3 * 10^{12}*3.5 * 10^8}{1800^2}

F = \frac{6.67408 * 5.3 * 3.5 * 10^{-11} * 10^{12} * 10^8}{1800^2}

F = \frac{123.804184 * 10^{9}}{3240000}

F = \frac{123804184000}{3240000}

F = 38211.1679012

F = 3.82 * 10^4N ---- Approximated

Hence the gravitational force between them is 3.82 * 10^4N

4 0
4 years ago
What term describes a set of software tools designed to increase the privileges of a user or to grant access to the user to port
san4es73 [151]

Answer:

A rootkit is a collection of computer software, typically malicious, designed to enable access to a computer or an area of its software that is not otherwise allowed (for example, to an unauthorized user) and often masks its existence or the existence of other software.The term rootkit is a concatenation of "root" (the traditional name of the privileged account on Unix-like operating systems) and the word "kit" (which refers to the software components that implement the tool).

4 0
4 years ago
Other questions:
  • Special characters that display on the screen but do not print are called _____________
    15·1 answer
  • The transmission control protocol (TCP) layer helps computers to communicate in which of the following ways?
    9·1 answer
  • What is the most important external issue when using social media in emergency management?
    6·1 answer
  • In a rear-wheel drive (RWD) system, the rear axle _______ the vehicle.
    11·1 answer
  • How to write greater than or equal to in excel if function
    7·1 answer
  • You're researching information about titanium bike frames. Which Web site is probably the least biased? The web site of a nation
    6·1 answer
  • How many bits does it take to represent the values from 0 to 255?
    9·1 answer
  • Under which menu option of a word processing program does a callout appear?
    7·2 answers
  • Name 3 coding languages
    6·2 answers
  • The _____ of a story describes the time and location of a story.
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!