Respuesta :
Answer:
Complete Python code along with step by step explanation is provided below.
Python Code:
# create a recursive countdown function that will count in decreasing order
def countdown(n):
if n >= 0:
print(n)
countdown(n-1)
# create a recursive countup function that will count in increasing order.
def countup(n):
if n <= 0:
print(n)
countup(n+1)
# driver code
def main():
# get input from the user
n = int(input("Please enter any number: "))
# call the countdown function if input n is zero or greater than zero.
# whether you choose countdown or countup for input n the outcome will be same in both cases
if n >= 0:
countdown(n)
# call the countup function for the remaining case that is n is less than zero.
else:
countup(n)
# call the main function
main()
Output:
Test 1:
Please enter any number: 5
5
4
3
2
1
0
Test 2:
Please enter any number: -6
-6
-5
-4
-3
-2
-1
0
Test 3:
Please enter any number: 0
0



Following are the python program to the given question:
Program Explanation:
- Defining two methods "countdown, countup" that takes one parameter.
- In both methods, it uses an if block that checks the parameter value and prints its value with the message.
- In the next step, the "n" variable is defined that inputs the value and uses the if block that checks the value and calls the above method accordingly.
Program:
def countdown(n):#defining a method
if n <= 0:#defining an if block that checks n value less than equal to 0
print('Blastoff!')#print message
else:#defining else block
print(n)#print number value
countdown(n - 1)#calling method countdown
def countup(n):#defining countup method that takes one parameter
if n >= 0:#defining if block that checks parameter value greater than equal to 0
print('Blastoff!')#print message
else:#defining else block
print(n)#print the parameter value
countup(n + 1)#Calling method countup
n = int(input("Enter an integer: ")) #defining n variable that inputs value
if n < 0:#defining if block that check n value less than 0
countup(n)#Calling countup method
else:#defining else block
countdown(n)#Calling countdown method
Output:
Please find the attached file.
Learn more:
brainly.com/question/16999822

