# Python 101 - Lesson 3

11-13 yrs old

14-18 yrs old

Computer Science

Technology

A VARIED OUTCOME Variables

Submitted By: Minecraft Education

September 8, 2020

#### Skills

• Creativity
• Critical Thinking

### Learning Objectives

• Decompose (break down) the steps needed to solve a problem into a precise sequence of instructions. 1A-AP-11
• Model daily processes by creating and following algorithms (sets of step-by-step instructions) to complete tasks. 1A-AP-08
• Systematically test and refine programs using a range of test cases. 2-AP-17
• Create programs that use variables to store and modify data. 1B-AP-09

### Guiding Ideas

In this lesson the students will learn:

- to create a variable and assign a string to it.

- to create a variable and assign a numerical value to it.

- to change the numerical value of a variable.

- the concept of world coordinates.

- to use predefined locations.

Tell the students that they need to help CodingMine with the development of their new farming software. This software will be used to help farmers in every step of the farming process from planting and sorting to selling the produce. Explain to the students that they will be using variables in this lesson and world coordinates.

### Student Activities

Coding Concepts:

- Variables

- World position

User Interface. In this lesson the students will:

- see displayed world coordinates in the top left-hand corner.

- learn to use the half coding window, giving the students the possibility to see the coding window and world position at the same time.

- use predefined given world locations, at the top of the coding window.

Syntax / Operators:

- Equals = :

Equals is used with variables to declare its value.

- Change += :

Increases the value by the defined amount.

- Change -= :

Decreases the value by the defined amount.

Coding Activities:

1. Activity 1: Sorting things out.

Explain to the students that the programmer needs their help to develop software that is going to sort the different fruit that the farmers are picking. The students will need to work out the correct sequence of buttons to press on the sorting machine. They will be doing this by creating variables for the different fruits and finishing off the code so that when it is run the correct sequence is shown.

2. Activity 2: Ideal planting spot.

Explain to the students that the developer needs their help to program a piece of code that will plant the correct crop in a desired location. The students need to do this by matching the world positions in the Minecraft world with the different location variables in the coding window. This is done by looking at the world position in the top left-hand corner when the player is standing in the right location. Once the students have found the location, they should place a block, using code, that corresponds to the type of block hanging above the location (melon block or pumpkin) using the place block at position command with that location variable as the position.

3. Activity 3: Are my calculations off?

Explain to the students that the data scientist needs their help to write three pieces of code that will calculate the cost of the fruit when the farmers are selling them. They will have to code three different calculations for different situations. Examples would be when the price of fruit increases or decreases and when the farmers add a new type of crop. Once calculated they will have to show the total cost in the chat using the say command. The students should then press the button that corresponds to the cost shown in the chat. Tell the students that they will be working on one piece of code in this Activity, adding additional parts as needed.

### Performance Expectations

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

Q. What is a variable?

A. A variable is a box/placeholder for a numerical value, piece of text, command, or another variable.

Q. How do you set the value of a variable?

A. Using equals, e.g. a = 1.

Q. If apple = 3 and we use apple+=2, what is the new value of apple?

A. 5.

Q. Each block in the world has its own unique coordinates. What is this called?

A. World position.

#### Skills

• Creativity
• Critical Thinking