Python 101 - Lesson 1 - All That Syntax
Python 101 - Lesson 1 - All That Syntax
EDUCATION.MINECRAFT.NET
1
THEME OVERVIEW
In this lesson, you will need to help a software development company called
CodingMine. They have created software, but there are all kinds of bugs within the
software. The CEO of the company needs the students’ help. The problem has
become widespread in many pieces of code that they wrote. The students need to
write down Python commands using the correct syntax and find and correct errors
in other already existing pieces of code.
LESSON OBJECTIVES
By the end of the lesson, students will:
• Understand what a computer language is
• Define an algorithm
• Recognize Python command syntax structure
• Differentiate the syntax when declaring strings or numbers
• Identify how to correct syntax errors
KEY VOCABULARY
Syntax – A set of rules used to create programing language structure
Syntax Error – A computer’s way of saying that the computer code is incorrect and
cannot run
Command Group – The first part of a python coding command, referred to as the
‘player’ part
Command Name – The second part of a python coding command, referred to as
the ‘say’ part
String – A piece of text in quotes within the code.
CODING CONCEPTS
• Computer Languages
To instruct a computer to do something, you need to talk to it in a language
it understands, just like people. There are many computer languages; some
of the ones used the most, which they may have heard of, are C++, Python
2
and JavaScript. Most computer languages, although they are all slightly
different, use the same coding concepts.
• Algorithms
When computers read code written in a computer language, they read it as
an algorithm. An algorithm is a list of commands that the computer reads and
carries out one after the other. The order in which the commands are given
to the computer is important. For example, when you are making a cake in
real life, if you have a recipe and you follow it in the correct order, you will
make a delicious cake. If you make it in the wrong order, it wouldn’t come out
correctly, even though all the ingredients are the same. An algorithm is like a
recipe and can seem complicated, but it is just a set of small steps being
carried out in the right order.
• Python
Python is a language that is used to communicate with a computer to make
it carry out certain tasks. Python is a powerful programming language that
can be used in many situations, from making web applications and data
analysis to programming artificial intelligence.
• Syntax
Syntax (in a programming language) is a set of rules that are used to create
the programming language structure, in a similar way that grammar is used
to create the structure of sentences in normal language. A software developer
must follow this structure to make his or her code run correctly.
• String
Explain to the students that a string is a piece of text in quotes “ “, an example
of this would be:
“Hello”
You can use other characters such as numbers inside the quotes. However,
these numbers would not have any mathematical value, and would just be
read by Python as text.
LESSON ACTIVITIES
3
Define the important vocabulary with students. (slide 3)
All students should log into Minecraft: Education Edition at this point and replicate
these exact steps so you can complete the first activity together.
Explanation:
The Python programming language is made up of a series of commands. The
general structure of a Python command is:
module_name.command_name(parameters)
player.whisper(parameters)
If you want to include some text in a parameters slot, it’s very important to include
speech marks around it.
4
For this activity, you will need to check which one of the commands written on the
computer monitors is correct and shows “hi” in the chat when run. Press the
mouse button on the right side of the monitor in the game if the code on the
screen looks correct.
After students click on the correct mouse button next to the monitor, Activity 1 will
be complete, and the door to the next Activity will open. When the mouse button,
next to any other monitor is pressed, bugs will appear, and you will keep trying
until you find the correct code.
Code Snippets:
5
Objective: Find the Missing Syntax Blocks and Fill in
Explanation:
“Syntax in Python involves using the right characters in the right place. The
programmer has asked for your help, as he cannot find out what syntax blocks are
missing from the commands on the monitors. There are syntax blocks in the chest
in the middle of the room. Use these blocks to fill in the missing syntax of the
commands.
You need to figure out what syntax is mission from the code on the TV monitors,
then place the matching syntax blocks onto the golden blocks around the room to
complete the statements.
Once the students have correctly placed each syntax block, they will have
completed Activity 2 and the door to the next Activity wil open.
Code snippets:
Monitor Missing Syntax Correct Code
1 – player.say”To show”) ( player.say(“To show”)
6 – player.say”2” ( ) player.say(“2”)
6
Activity 3: What is the Correct Number? (Slides 25-29)
Objective: Find the Correct Sum and Choose it
“Try and solve the sum below in your heads and see how long it takes.”
(2+6) *(4-2)
The goal is to demonstrate the advantage of using a computer when they solve the
same sum using code.
Explanation:
The data scientist has asked for your help to find out what the correct answer for
three sums. You will need to calculate and display the answers of the three
expressions on the TV monitors. You will need to write some code in the coding
window [c] to calculate the correct answer and then press the corresponding
button.
When the students have selected each answer correctly, Activity 3 and the lesson is
complete.
Code Snippets:
player.say(45+2505) Answer: 2550
player.say(255/15) Answer: 17
player.say((27+4)*(55-52)) Answer: 93
LESSON CONCLUSION
Ask students about the skills that they have learned during the lesson to reinforce
the concepts learned. (slides 30-31)
1. What is syntax?
Answer: Syntax a set of rules that are used to create the programming
language structure.
2. Do we use quotes when we want to show a piece of text in the chat?
Answer: Yes
7
3. Are numbers used with or without quotes if we want to use their
numerical value?
Answer: Without
4. What syntax do we place around the parameters of a command?
Answer: Parenthesis ()
These questions are also available as a printable handout at the end of this
document. They can be used as a formative assessment for this lesson’s learning
objectives.