Python Coding In Minecraft: Education Edition With .

Transcription

Python Coding inMinecraft: EducationEdition with MicrosoftAzure Notebooks1

Educator Crafting Table2

00 Setting Up the Coding Window01 Introducing Python Coding in theNotebook Editor02 Get Coding with Tutorials03 Python Variables in Notebooks04 Syntax of Coordinates with World SetCommand in Notebooks05 Python Event Handlers in Notebooks3

00Let’s Get Set UP

Sign in with your education account andpassword5

Create New WorldThere are lots ofoptions, but for now,create new.6

Give your world a good name!7

Use the settings best for your lessonCreative,PeacefulFlatworlds areeasy tocode!8

Use the settings best for your lessonShowcoordinates- soimportant!Reducechunks ifyour gamelags9

New Classroom Settings10

New Classroom SettingsPerfect weatherand always dayare lessdistracting!11

New Classroom SettingsYou can enterany link (maybeinstructions!)and customizefor yourstudents.12

The Keyboard in Minecraft: Education Edition13

Try it out!Tutorial 1. Movement MinecraftEducation Edition14

Suggested “go-to” settings for your firstgame15

Questions?

01First Lesson to Introduce PythonCoding in the Notebook Editor inMinecraft: Education Edition

First Steps into Python Coding with Minecraftin NotebooksYes, you CAN code in Python, and yes, your students willlove to code in Minecraft: Education edition!Here is a first step into actual Python code that yourstudents can create and execute right in their ownMinecraft world.This is an introductory lesson. You do not have to do all of these commands, or youcan start with these and do more.Be flexible! Be brave! Get started and get coding!18

Building on successThe best way to code is from success to success. Start with one line of code that you know works. Run it. Besuccessful.Then edit it and see if you can make an edited line of code thatworks. Once you make sure that first line of code is working, add asecond line. In other words, build on success.Fixing errors is part of coding. Fixing errors after adding three linesof code is ten times harder than fixing errors after adding one lineof code.So keep changes small and you can get things fixed pretty quickly.Try not to worry about errors. Roll with the punches.Computing is learning.It just takes time to get over the bumps.19

Growth Mindset!Computers are picky, picky picky. You cannot ignore a comma, period orlower case letter. For example, if you have one little space at thebeginning of a line, or you use a "special" character, computers canget upset. They need all the details to be exact.So look at every single thing you typed if you find you made an error.Don't worry; every coder makes mistakes and learns from them!Have fun!You are in the driver's seat on an amazing adventure. You are creatingthings where usually you are just going along for the ride. Instead oflooking at other people's art, you are the artist. Enjoy the process.Realize that you learn as much from the mistakes as you do from thesuccesses.Coding is the best.20

Code FollowsTeachers, students should begin theircode in a flat world. Students should not begin bytyping all of this code. Begin with a single command,and test. Edit the command and test. Make another version of thecommand, and guess what? Test. Add new commands after theyhave succeeded.For example, after saying Hello World, they should changethe command to their own message, and add an additionalmessage of their own. Other edits could include summoningother animals, for example, a parrot. Try making small editsto the teleport command.# First Lesson Commands: Comment, Say, Teleport, Summon# This is a comment; comments begin with a hashmark# Comments are very important and should be in every program# Comments do not execute - they are notes for programmers.## All first programming endeavors should begin with Hello World!say("Hello World")### Summon is like spawn. Names must be exactly correct.summon("mooshroom")## This is a teleport command. You can edit the 3 numbers.# !!! This is meant for a FLAT WORLD !!!player.teleport("10 5 10")## What do these three commands do?# Let's make sure the animal survives!say("Looking up!")player.teleport(from me( 0,25,0))summon("chicken")## Ready for more? Here is more complex coordinate use!world.fill("2 2", "5 3 5", "stone")21

Questions?

02Get Coding with Tutorials23

BillboardsShow title(title, subtitle, action bar) One of the simplest tutorials in the Python notebook editor is Billboards. It uses the command show title.This simple command has very exciting results.Recall previous experience using the command say:say(“Hello World!”)The say command required a command name: say, parens () and a string inquotation marks: “Hello World!”In the show title command, we enter our own information in the quotation marks,as well.24

Billboards# Put your own words in this command.show title(“Mooshrooms are great!”)Remember that computers are picky. You cannot skip the underscore.You cannot type:show title with a space and no underscore. You cannot type showtitle with no space.Students can edit the string to create different titles.Then they can go on to adding a subtitle. The title and subtitle are two parameters,separated by a comma.Interesting observations can be made about what happens if you “accidentally” forgetthe comma.25

Billboards# What kind of error is produced if you miss the comma?show title(“Coding”,”is the best”)A third parameter is allowed.As a hint, have students keep the text short.Going to three parameters requires careful error checking.Check quotation marks and commas.Don’t forget that last paren!26

Billboards# Be careful with syntax when adding the third parameters, for the action barshow title(“Coding!” , “Lets me be in charge.” , “Show me the commands!”)27

Extension Activity - Variables As an extension, you can use this command with variables. If your students are comfortable with variables, or if you have already tried the introduction tovariables, you can add another level to your lesson.The extensions offered in the tutorialin-game add even more parameters.Go ahead and use the NotebooksTutorial in the game now.As a hint: It is suggested that studentsdo not experiment with large numbersfor these settings. ] Go coding!28

Questions?

03Variables

VariablesOne of the most important early conceptsfor students to understand is the purposeand use of variables in coding.Many students already understand theenvironment of Minecraft.They understand that there are conditionsin Minecraft that change, such as theweather.Making the connection to variable use iseasier because students can observe forthemselves what the changing value ofthe variable "means" in the game.31

Variablesworld.weather In the new Notebook interface,world.weather is the name of the locationwhich stores the current weather in theirMinecraft Education game. In the coding window, the current state ofthe weather can be accessed as well aschanged. Try this out as an exciting introduction todealing with variables in Minecraft Pythoncoding in Notebook.To extend this activitySearch out other values to use besidesthunder. How can students research thisinformation and test their guesses in thegame? (Hint: the terms in the chatcommands are frequently similar or evenidentical!)32

VariablesCreating variables with strings for say commandsCan students improve on the greeting?Student names are not “Anonymous’– of course!Have them edit the code to addtheir own names.One trick programmers learn aboutstrings is that adding a space at theend of a string can make the outputlook better when strings areconcatenated (added together.)33

Questions?

04Coordinates, Syntax and Parameters35

Coordinates, Syntax and ParametersCoordinates are a very importantkind of information in a world madeof blocks! Coordinates give the exactlocation of blocks – and of yourplayer and important locations - inthe Minecraft world.We will look at ways to correctly usecoordinates in the Python Notebookeditor, utilizing the world.set andworld.fill commands.36

Coordinates, Syntax and ParametersWhat is Syntax?Languages use syntax, a system of order that indicatesmeaning.Syntax has to do with using symbols and words in the correctorder to express meaning.Sometimes we can understand things even though they arenot in the expected order.It can be confusing, though. This is why we tell jokes aboutthings like commas. “Let’s eat, Grandma” is very different from“Let’s eat Grandma.” Usually, the order of the words and symbols is very important to the meaning of commands.Python Notebooks has more than one way in which coordinates can be written.This can be powerful and helpful. Some commands allow you to be flexible and pick thecoordinate syntax you prefer. Other commands are more picky.37

Coordinates, Syntax and ParametersParametersThe command world.set requires twoparameters. Parameters give commands theinformation they need to do their job.world.set needs location and a block to placein that location.We think of the command like this:world.set( location , block )38

Coordinates, Syntax and ParametersParameters Note that the block parameter isasking for a Minecraft block likecake, and the syntax is to use thecorrectly spelled name (capitalsmatter!) and to enter the word inquotation marks. So a block might be "cake" or"dirt" or "diamond block" Since you know that syntax isimportant, you know that you willneed quotation marks around theword cake and that you cannotcapitalize the word or you will get asyntax error.39

Coordinates, Syntax and ParametersThe command world.fill uses the coordinates of two opposite corners ofa box shape to define an area to fill with a block.We think of the command like this:world.fill( location , location , block )(To help students visualize this, grab a tissue box or cereal box and showthe opposite corners.)40

Coordinates, Syntax and ParametersBlocks you may use in the set or fill commands:"double plant" "bed" "web" "red flower" "yellowflower" "sapling" "log" "leaves" "chest" "redmushroom" "dirt""stone brick" "cobblestone" "quartz block""iron block" "diamond block" "emerald block" "log""lapis lazuli block"41

Questions?

05Event Handlers

Event HandlersEvent handlers are the big responders in coding. They arethe bridge between code and the outside world.Event handlers are code that waits for an event, such as anaction by a player in a Minecraft world, and they run codein response to this event.Event - an action, outside the code, that is recognized andresponded to inside the code.Event handler - code which “listens for” and responds to(handles) events outside of the code.44

Event HandlersExamples of events in Minecraftinclude things like a player walking,a block breaking, or a certain wordbeing said in chat. Code for eventstypically begins with the word "on"on chat event( chatcommand , function to call ) isa built-in event handler in theNotebooks editor.45

Event HandlersHere we have the on chatcommand waiting for “Hello” inchat, so it can call the functioncalled chatter.The code is entered, and andrun is chosen, but no visiblechange will occur in the gameuntil the event handler "hears"what it is "listening" for.The event handler is "listening forHello in chat. When it hears Hello, itwill call the function named chatter.46

Event Handlers47

Event Handlers48

Event Handlers49

Questions?

AcknowledgementsDebbie Alexander is an educator, computer scientist andGlobal Minecraft Mentor and a grandma! Debbie regularlycontributes to the Community Boards and to this guide byproviding her insights into teaching Python with Minecraftand Azure Notebooks.51

Thank you!

Yes, you CAN code in Python, and yes, your students will love to code in Minecraft: Education edition! Here is a . first step . into actual Python code that your students can create and execute right in their own Minecraft world. This is an introductory lesson. You do not have to do all