Python 101 - Lesson 9

Python 101 - Lesson 9

11-13 yrs old

14-18 yrs old

Computer Science


ALL FUN AND GAMES Developing code and decomposition

avatar Submitted By: Minecraft Education

September 8, 2020


  • Creativity
  • Critical Thinking

Learning Objectives

  • Create programs that include sequences, events, loops, and conditionals. 1B-AP-10
  • Create procedures with parameters to organize code and make it easier to reuse. 2-AP-14
  • Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process. 1B-AP-11

Guiding Ideas

In this lesson the students will learn:

- how to tackle writing larger codes.

- the concept of decomposition.

- to use all the coding concepts they have learned, in one larger code.

- how to add to a relative position.

Tell the students that the game developers at CodingMine are writing a game called Agent Invader. However, the developers have been having some problems with the controls, firing system, and scoring system. Explain to the students that, unlike the other lessons, they will be developing and writing one large code throughout this lesson. Each Activity will cover a different aspect of the game. By the end, the students will have written a fully working game. Explain to the students that, in this lesson, they will be working on one continuous code in the coding window throughout the Activities.

Student Activities

Coding Concepts:

- Decomposition

- Adding to relative positions

Syntax/ Operators: greater than, less than, greater than or equal to, less than or equal to

Coding activities: (30 min)

1. Activity 1: Game controls

Explain to the students that the games developer needs their help to code the controller that will move the Agent in the game. Explain to the students that there are two ‘buttons’ on the controller, blue is the control for left and red is the control for right. Tell the students that they need to write some code so that when their character stands on the red or blue pad the Agent moves in the correct direction.

2. Activity 2: Firing system.

Explain to the students that the programmer needs their help to code the firing system that will make the Agent shoot the blocks in the game. Tell the students that there are gold blocks above the Agent in the game, that it needs to shoot. This Activity is in two parts.

3. Activity 3: Scoring system

Explain to the students that the next games developer needs their help to code a scoring system for the game, as well as the start and finish splash screens. At the start of the game the game title should appear and then each time the Agent shoots a gold block, the score should go up by one. The total score to win the game should be 15 after which a lightning effect should hit the Agent and a splash screen should appear, congratulating the player on winning the game.

Performance Expectations

Ask the students about the skills that they have learned during the lesson, to reinforce the concepts.

Q. What is decomposition?

A.  Decomposition is the act of breaking down a long code into smaller parts.

Q. Why is decomposition useful?

A. Decomposition is useful when writing big projects, making them easier to understand, to test and to make the code work correctly.

Q. What does this symbol mean, <=?

A. Less than or equals to.

Q. How do you make a while loop repeat continuously?

A. By setting its condition to True.


  • Creativity
  • Critical Thinking