Week 11

Build Your Own Commands

Your mission: Group useful commands, give them a name and use them again.

New coding words

  1. function
  2. define
  3. call
  4. parameter
  5. reusable

What the coding words mean

  1. function: A named group of instructions that performs a task.
  2. define: To create a function and describe what it should do.
  3. call: To run a function by writing its name with parentheses.
  4. parameter: A variable that allows a function to receive information.
  5. reusable: Able to be used again without rewriting all the commands.
Code along

Build a reusable cheer

Define a cheer function and call it using two different names.

Python coding spaceReady to run
.py

Tab indents. Esc then Tab leaves the editor. Ctrl/⌘ + Enter runs your code.

Output (Shell)What your program does
Select Run my code to try this program.
Opening your coding space…Each activity has its own saved code.
Mini project

Turtle Shape Factory

Build a function that draws squares in different sizes and colours.

Python coding spaceReady to run
.py

Tab indents. Esc then Tab leaves the editor. Ctrl/⌘ + Enter runs your code.

Output (Shell)What your program does
Select Run my code to try this program.
Turtle drawing

Run your code to draw here.

Opening your coding space…Each activity has its own saved code.

Your mini-project to-do list

0 of 4 completed

Complete these activities in the mini-project editor above. After each change, select Run my code to check your program’s output or drawing.

Save your finished mini project

Select Download my work and save the file as week_11_turtle_shape_factory.py. The .py ending tells us that the file contains Python code. Keep this file as a copy of your finished program.

Debugging detective

Chi Opara, your course guide

Knowledge check

Question 1

Which Python word creates a function?

Choose one answer
Question 2
Python codecheer(name)

What is the parameter?

Your answers are checked in this browser and are not submitted.

How are you getting on so far?

My checklist

Finished Week 11?

This progress is saved only in this browser.