Lab Assignment 6, TCSS 142 solution




Rate this product


  1. Lecture Exercises (20%)

Show the following exercises you were to create during the lecture:

  • py
  • py
  • py


  1. Functions 1 (25%)


  1. Download the program 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


  1. 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)




  1. Functions 2 (25%)

You are to restructure the program 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.



  1. Problem solving with functions (30%)

Solve problem 21 (Rock, Paper, Scissors Game), p. 233 using modular design.

—–  THE END —–