0% found this document useful (0 votes)
3 views21 pages

Python Syntax and Math

The document outlines a structured activity for teaching Python syntax and math through a Minecraft game setup. It includes steps for creating a game world, basic controls, understanding Python syntax, data types, and math operators. Additionally, it presents quizzes and activities for students to practice correcting syntax errors and solving math problems within the game context.

Uploaded by

ngyowei
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views21 pages

Python Syntax and Math

The document outlines a structured activity for teaching Python syntax and math through a Minecraft game setup. It includes steps for creating a game world, basic controls, understanding Python syntax, data types, and math operators. Additionally, it presents quizzes and activities for students to practice correcting syntax errors and solving math problems within the game context.

Uploaded by

ngyowei
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

(Python Syntax and Math)

Activity / Practice
Setting up the game:

Step 1

Click on “Play” to start


creating a Minecraft world

Click on this icon to change a


player’s avatar and skin

Step 2

Click on “VIEW LIBRARY”


Step 3

Click on “SUBJECT KITS”

Step 4

Click on “COMPUTER SCIENCE”


Step 5

Click on “CODING WITH PYTHON”

Step 6

Click on “PYTHON 101”

Step 7
Step 8

Basic Controls in Minecraft:

Using your mouse


• Move the mouse • • Look around

• Left mouse button • • Mine or attack

• Right mouse button • • Use a piece of inventory

• Scroll wheel • • Toolbar selection

Using your keyboard

W Moves your player forward

A Moves your player left Space Makes your player jump

S Moves your player backward Shift Hold to make your player crouch

D Moves your player right Esc Pauses the game or exits chat mode

E Opens your inventory 1 9 Toolbar selection


-

Q Drops an item
What is Python Syntax and Math?

Students will need to help a software company called “CodingMine” by finding


and fixing all the bugs in the software they create.

Students will need to type out Minecraft Python commands using the correct
syntax. Spot the errors and fix it in other already existing codes.
Understanding Python Syntax

Syntax is a set of rules that are used to create the coding language structure.
A coder must follow this structure to make their code run correctly.

You can think of syntax like the grammar used to create structures in our
English language.
ENGLISH PYTHON

The player says, “Hi!”. [Link](“Hi!)

Player says hi playersay(“Hi!”)

Hi says player [Link](Hi)

This is how it will look like in


block and syntax form

Even a single difference between


“s” and “S” results in a mistake
Python Syntax Structure
Do not worry if the line above is a little bit confusing, lets break it down!
Here is how the structure will look like:

command_group.command_name(parameters)

[Link](“Hi”)

The actual action that


the group will be doing

Which group will be used The name of the action


this group will be doing
More examples

1.

2.

3.
Data Types

1. Integers (numbers)
e.g., 1, 79, 123.2, -55

2. Strings (words)
e.g., “Hi”, “:)”, “it is so sunny”, “I have 4 apples”

Let us talk more about strings:

- Strings are surrounded by double quotation marks ( “ “)

- Strings can contain both words and numbers

“123” DOES NOT EQUAL TO 123

This is a string This is a number


Surrounded by “ “ Not surrounded by “ “

Adding numbers:
123 + 123 = 246
Adding strings:
“123” + “123” = “123123”
Adding numbers to strings:
123 + “123” = error
Python Simple Math Operators

Math Operators Use Description

Addition + a = 10 + 2 a equals 10 plus 2

Subtraction - a = 10 – 2 a equals 10 minus 2

Multiplication * a = 10 * 2 a equals 10 times 2

Division / a = 10 / 2 a equals 10 divide 2


Order of working for math operators

Operator Operations Order of working

() Brackets Always evaluated first

* Multiplication Evaluated second.


If there are several,
/ Division they will be evaluated from left to right.

+ Addition Evaluated second.


If there are several,
- Subtraction they will be evaluated from left to right.

− Example 1:
y=2*5+3*5+7 (Leftmost Multiplication)

y = 10 + 3 * 5 + 7 (Multiplication before Addition)

y = 10 + 15 + 7 (Left Addition before Right)

y = 25 + 7 (Last Addition)

y = 32

− Example 2:
y = 15 - 9 / 3 * (1 + 2) (Brackets are always evaluated first)

y = 15 - 9 / 3 * 3 (Leftmost division evaluated)

y = 15 - 3 * 3 (Multiplication before Subtraction)

y = 15 - 9 (Last Subtraction)

y=6
POP QUIZ
MATH OPERATORS QUIZ
Starting the game
Step 1: Talk to the CEO

Talk to the CEO to activate the game!

You can talk to him by right clicking on the mouse

ACTIVITY #1: Correct Syntax

Talk to the Developer to activate


the game!

You will have to figure out which


one of the commands on the
computer monitors is written
correctly
Press on “C” to open your code builder to test out the codes by
typing out the exact commands shown on the monitors

Red underline
indicates an error

You will be able to see the exact problems with your code.
Also because there is an error, you will not be able to run this project
Once you have decided on the correct command, right click on the
black button located beside the monitor

If you click on the correct button, you will complete the activity!
If you click on the wrong button, bugs will appear
ACTIVITY #2: Missing Syntax

Talk to the Programmer to activate


the game!

You will have to place the correct


blocks on the gold plate to advance
to the next stage.

Right click on the chest in the middle of the room


Drags the blocks into your hot bar accordingly
Place the correct blocks on top of the gold plates, according to the code
on the monitors

If you have placed the right blocks, it will be displayed on your screen!
ACTIVITY #3: Math Operators

Talk to the Data Scientist to


activate the game!

You will have to work out the math questions on the monitor according to
how we discussed earlier in the lesson
Click on the button that you think is correct

Once you are done with the 3rd activity you would have completed the lesson!

You might also like