Question: import math import random import string import collections import datetime import re import time import copy # YOUR CODE BELOW... def writeVertical(n) : # your
import math import random import string import collections import datetime import re import time import copy # YOUR CODE BELOW... def writeVertical(n) : # your code here... # end def def digitalSum(n) : # your code here... # end def
Question 2: The digital sum of a number n is the sum of its digits. Write a recursive function called 'digitalSum' that takes a positive integer n and returns its digital sum. For example, print(digitalSum(1984)) will return 22 because 1 + 9 + 8 + 4 = 22 The function prototype MUST be: def digitalSum(n) : Question 3: Write a Python function called 'exponents' that uses recursion to calculate and display the value of 'a' to the power 'b'. NOTE: Both 'a' and 'b' can be positive or negative and any number raised to the exponent 0 is 1, and if the base is 0, the result will always be 0. For example, print(exponents(3, 3)) will display: 27 For example, print(exponents(3, -4)) will display: 0.012345679012345678 The function prototype MUST be: def exponents(a, b) :
def exponents(a, b) : # your code here... # end def def invertedImage(top, bottom, n, s) : # your code here... # end def def main( ) : writeVertical(98312) print("===") writeVertical(0) print("===") writeVertical(-123456789) print("===") print(digitalSum(1234)) print("===") print(exponents(3, -4)) print("===") print(exponents(16, 0)) print("===") print(exponents(0, 9)) print("===") print(exponents(-18, 7)) print("===") print(exponents(12, 12)) print("===") invertedImage('*', '#', 6, 0) print("===") invertedImage('@', '^', 18, 0) # end main( ) if __name__ == "__main__" : main( ) The OUTPUT should be EXACTLY as displayed below: 9 8 3 1 2 === 0 === - 1 2 3 4 5 6 7 8 9 === 10 === 0.012345679012345678 === 1 === 0 === -612220032 === 8916100448256 === ****** ***** **** *** ** * # ## ### #### ##### ###### === @@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@ @@@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@ @@@@@@@@@ @@@@@@@@ @@@@@@@ @@@@@@ @@@@@ @@@@ @@@ @@ @ ^ ^^ ^^^ ^^^^ ^^^^^ ^^^^^^ ^^^^^^^ ^^^^^^^^ ^^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
