Question

# Function Example: Write a Python function that receives two integer arguments and writes out their sum...

Function Example: Write a Python function that receives two integer arguments and writes out their sum and their product. Assume no global variables.

def writer(n1, n2):

sum = n1 + n2

product = n1*n2

print("For the numbers", n1, "and", n2)

print("the sum is", sum)

print("and the product is", product)

...

1) Create a PYHW2 document that will contain your algorithms in flowchart and pseudocode form along with your screen shots of the running program.

2) Create the algorithm in both flowchart and pseudocode forms for the following two functions:

A. Write a Python function that receives a real number argument representing the sales amount for videos rented so far this month. The function asks the user for the number of videos rented today and returns the updated sales figure to the main function. All videos rent for \$4.25.

B. Write a Python function that receives three integer arguments and returns the maximum of the three values.

3) Create the algorithm in both flowchart and pseudocode forms for a main program that tests the two above functions.

C. Write a Python main program that calls both above functions to shows that both functions work properly.

Programming Notes:

Function Definition -- def functionName( parameter list )

receives -- this denotes a value that is passed to the function as a parameter.

ask the user -- this denotes a value that the functions requests of the user.

return -- this denotes a value that is returned from the function to the calling program.

program including both functions and the main program in one python source file.

'''
Python version : 3.6
Python program to create and test 2 functions
'''

def calculateSales(amount):
'''
Function that receives a real number argument representing the sales amount for videos rented so far this month
The function asks the user for the number of videos rented today and returns the updated sales figure to the main function.
All videos rent for \$4.25.
'''

# input the number of videos rented today
rented = int(input('Enter the number of videos rented today: '))
# return the updated sales
return(amount + (rented*4.25))

def maximum(value1, value2, value3):
'''
Function that receives three integer arguments and returns the maximum of the three values.
'''

# set max_value to value1
max_value = value1

# if value2 > max_value, update max_value to value2
if value2 > max_value:
max_value = value2

# if value3 > max_value, update max_value to value3
if value3 > max_value:
max_value = value3

return max_value

# test the functions
sales = calculateSales(0)
print('Updated sales: %.2f' %sales)
sales = calculateSales(sales)
print('Updated sales: %.2f' %sales)
print('Maximum of 35, 70, 55: %d' %(maximum(35,70,55)))

#end of program

Code Screenshot: Output: #### Earn Coins

Coins can be redeemed for fabulous gifts.