0% found this document useful (0 votes)
43 views

Python 101 - Lesson 1 - All That Syntax

Uploaded by

llejoy703
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

Python 101 - Lesson 1 - All That Syntax

Uploaded by

llejoy703
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Educator Guide

Python 101 - Lesson 1 (Azure Notebooks)


45-60 minutes

All That Syntax


PYTHON COMMAND STRUCTURE AND 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

THINGS TO KEEP IN MIND


• Remind students that there may be more than one solution for each of the
activities.
• Encourage students (and demonstrate if needed) how to take a screenshot
of the coding solutions and include their explanations.

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

Direct Instruction (Teacher-Led; “I Do”)


Today, we will start a new computer science unit called, “Python 101”. We are
going to transition over to using Python, a text-based coding language. This
version of Python uses Azure notebooks. (slide 1)

Review the lesson objectives with students. (slide 2)

3
Define the important vocabulary with students. (slide 3)

You will need to help a software development company called CodingMine by


finding and fixing all the bugs in the software they create. The CEO of the company
really needs the student’s help for this project. 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. (slide 4)

Explain the concept of syntax to students. (slide 5-6)

Guided Instruction (Teacher Modeling; “We Do”)


Demonstrate how to locate and find the Python 101 lesson, “All that Syntax” from
the in-game library. Showcase the spawn point for students and then explain that
they will start their lesson by talking to the NPC, the CEO of CodingMine. (slides 7-
9)

All students should log into Minecraft: Education Edition at this point and replicate
these exact steps so you can complete the first activity together.

Activity 1: Which One is Right? (Slides 10-19)


(Hint: The students will have to talk by right clicking on the non-player-character
{NPC} to start an activity)
Objective: Check Each Code for Accuracy

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)

An example of a command is the whisper command. The whisper command is very


similar to the say command.

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:

Computer Message Correct/Incorrect


Computer 1 player(say)Hi Incorrect
Computer 2 player.say”Hi” Incorrect
Computer 3 player.say(“Hi”) Correct
Computer 4 say() Incorrect

Independent Work (Teacher Support; “You Do”)


Activity 2: What is Missing? (Slides 20-24)

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”)

2 – player.say(“text on) “ player.say(“Text on”)

3 – player.say(the screen) ““ player.say(“the screen”)

4 – player.say”we use quotes” ( ) player.say(“we use quotes”)

5 – player.say2 (““) player.say(“2”)

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.

You have the following mathematical symbols available:


• Addition: +
• Subtraction: -
• Multiplication: *
• Division: /

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.

You might also like