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
Alright, so im currently trying to pass a computer science class. i need it done in a little under 2 weeks. Ill just ask the one
Alla [95]

Answer:

B. Mesh

Explanation:

5 0
2 years ago
Hjnjjjhhbbfg66ui998876dch
GalinKa [24]
What is your question? I’ll try my best to help
4 0
2 years ago
Implement a sublinear running time complexity recursive function in Java public static long exponentiation (long x, int n) to ca
Charra [1.4K]

Answer:

Following are the code block in the Java Programming Language.

//define recursive function

public static long exponentiation(long x, int n) {

//check the integer variable is equal to the 0.

if (x == 0) {

//then, return 1

return 1;

}

//Otherwise, set else

else {

//set long data type variable

long q = exponentiation(x, n/2);

q *= q;

//check if the remainder is 1

if (n % 2 == 1) {

q *= x;

}

//return the variable

return q;

}

}

Explanation:

<u>Following are the description of the code block</u>.

  • Firstly, we define the long data type recursive function.
  • Then, set the if conditional statement and return the value 1.
  • Otherwise, set the long data type variable 'q' that sore the output of the recursive function.
  • Set the if conditional statement and check that the remainder is 1 and return the variable 'q'.
4 0
2 years ago
To achieve the maximum confidentiality and integrity found in a completely secure information system would require that the syst
fgiga [73]

Answer:

The answer is "Option a".

Explanation:

Privacy is a set of rules, which limiting access to the data, and integrity ensures impartiality, accuracy, and reliability is assured to ensure, which authorized persons can have secure access to the data.

The system needs no access for everyone to achieve its secrecy and integrity contained in a completely safe data system, that's why the given statement is "true".

5 0
3 years ago
You are working on a project and need to be able to access the content from home and share the files with other team members. Th
inn [45]
Local server so you can all you use if you guys are near
5 0
3 years ago
Read 2 more answers
Other questions:
  • Because public key encryption requires the use of two different keys, it is also known as _____ encryption
    13·1 answer
  • What happens if you move unencrypted files into an encrypted folder?
    5·1 answer
  • The top-down approach is an appropriate strategy for most
    13·1 answer
  • Write a python program that requests a word (with lowercase letters) as input and translates the word into pig latin. The rules
    15·2 answers
  • Level of comfort that people feel
    10·1 answer
  • What kind of server connects a remote system through the internet to local serial ports using tcp/ip?
    9·1 answer
  • In learning information security, it is important to understand that threats to your company's information assets are present 24
    13·1 answer
  • . What is the relationship between frequency, wavelength and speed of a wave?
    15·1 answer
  • Which group scope can be used to assign permissions to resources only in the domain in which the group is created
    12·1 answer
  • In large organizations, database design and management is handled by a database _____.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!