Python Skills Worksheet 3a Functions
Python Skills Worksheet 3a Functions
Worksheet 3a Functions
1. Create a series of functions for a robot to do your household chores
Add some function calls at the end of the program so that the robot will do them
print ("\n")
def vacuum():
def setTheTable():
print("Place cups")
vacuum()
print ("\n")
setTheTable()
1
Worksheet 3a
Practical programming skills in Python
Use the following function calls to put together a complete game of Tic Tac Toe.
Rewrite them and repeat them (on paper) in an order that would allow you to play the
game. You can do this as a flowchart instead if you prefer.
Test the game by playing against someone else (you play as the player, they play as the
computer). Neither one is allowed to do anything that isn’t in the program you’ve designed.
drawGrid()
playerChooses()
checkIfSomeoneWon()
computerChooses()
checkIfSomeoneWon()
Download the Tic Tac Toe program (L3 WS3a Ex2 tic_tac_toe.py).
The subroutines are already completed for you, all you need to do is uncomment the calls
at the bottom of the program. You can copy each one as many times as you need to.
Test the program thoroughly – make sure it works if you win, lose or draw (it might take a
few goes to lose successfully!).