Description
Functions 1 (25%)
- Download the program oops.py. It contains several mistakes that should be fixed so that the program produces the following output:
x = 10.01 and y = 8.0
x = 10.01 and y = 867.5309
The value from main is: 867.5309
z = 5
- Perform paper and paper trace of the program given below to determine what the program will print:
def main():
soda = “coke”
pop = “pepsi”
coke = “pop”
pepsi = “soda”
say = pop
carbonated(coke, soda, pop)
carbonated(pop, pepsi, pepsi)
carbonated(“pop”, pop, “koolaid”)
carbonated(say, “say”, pop)
def carbonated(coke, soda, pop):
print(“say “, soda, ” not “, pop, ” or “, coke)
main()
- Functions 2 (25%)
You are to restructure the program boughtme.py into functions, including functions with parameters, and main. For example, the first line of each verse is exactly the same other than the animal name – use the animal as the argument; animal talk lines (cat goes…, hen goes….) repeat as well following a pattern.
- Problem solving with functions (30%)
Solve problem 21 (Rock, Paper, Scissors Game), p. 233 using modular design.
—– THE END —–