test

This worksheet tests understanding of Python functions through a pet simulator project. It covers defining functions with def, using parameters, the return statement, and saving returned values back into variables. Questions also explore function calls with no arguments and the benefits of modular code.

This is a 10-question catch-up worksheet for a Python programming session on building a pet simulator. It is designed for students who need to review the concepts taught in L3108 Term 4 Session 6. The worksheet asks learners to circle the correct answer for each multiple-choice question.

The first set of questions covers the basics of defining functions in Python. Q1 asks which keyword creates a function, with options including def, fun, make and function. Q2 and Q3 test understanding of parameters and how a function modifies a variable like hunger when called and the result is assigned back.

Q4 focuses on the return statement and what it does inside a function. Q5 repeats the pattern with a variable called fun and a play function that adds 30. Q6 explains why the assignment hunger = feed(hunger) is necessary to save the new value, rather than just calling the function alone.

Q7 and Q8 address the show_stats function, which prints all five of the pet's stats and takes no arguments. The questions check whether students understand that empty brackets mean the function does not need any values passed in. Q9 asks what happens to hunger at the end of each day in the simulator.

The final question, Q10, asks why it is useful to put each activity in its own function. The correct answer explains that it makes the code easier to read and each function can be reused. The worksheet also includes spaces for the student's name, class and date.