Sale!

Lab Assignment 6 TCSS 142 solution

$30.00 $25.50

Category:

Description

5/5 - (1 vote)

OBJECTIVE

The objective of this assignment is to give you practice with functions.

ASSIGNMENT SUBMISSION

While the lab instructor walks around checking lecture exercises (pre-lab) on individual basis, start working with the partner of your choosing on exercise sets 2 and 3. Once you are done with a set, check with the one of the other pairs sitting next to you regarding their progress – help each other. Then, as a pair, present your solutions to the lab instructor. Each student is to have his version of the programs/answers and be capable of presenting them for the pair. The presenter will be chosen at random by the lab instructor. All the exercises other than the last set need to be shown to the lab instructor before leaving the lab for full credit. The last exercise set may be finished at home and is to be submitted via Canvas before the next lecture. Use IDLE unless indicated otherwise.

1. Lecture Exercises (20%)
Show the following exercises you were to create during the lecture:
• fightSongBetter.py
• params.py
• transposeFunctions.py

2. Functions 1 (25%)

a. 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

b. 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()

3. 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.

4. Problem solving with functions (30%)
Solve problem 21 (Rock, Paper, Scissors Game), p. 233 using modular design.
—– THE END —–

Lab Assignment 6 TCSS 142