GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing minecraft.makecode.com — Unplugged Activity: Walk Around the House Unplugged Activity: Walk Around the HouseThis activity works best with a partner. You will write instructions for your partner to walk completely around the outside of a Minecraft house and return to the start. You will need a chair and some way to write things down. Place the chair in the center of the room. The chair represents a Minecraft house. Your partner should stand next to one of the corners of the house. Your goal is to write the instructions for your partner to walk all the way around the house, using these two commands: Your pseudocode will probably end up looking something like this: Have your partner follow your algorithm to prove that it works. Now notice that this is eight lines of code, and many of the lines repeat. In particular, the following two lines of code repeat four times: Programmers like to take shortcuts. A program that has fewer lines of code takes up less room in memory, and ultimately the shorter your program is, the easier it is to find mistakes. Whenever you have code that repeats, you have an opportunity to use a loop to simplify your code. How could this be shortened? How about: Go ahead and follow this revised code to prove that it works. You have just rewritten eight lines of code as three lines of code by using a loop. The "repeat" command creates a loop. The code within the loop gets repeated a certain number of times, and then the program exits the loop. Types of loops in MakeCodeComputers use loops to repeat sets of instructions under different conditions. Here are some examples of loops you will find in MakeCode. See if you can think of some different types of activities that would be appropriate for each type of loop. Counted loopsRepeat n timesFor index 0 to nBoth Similar to a While (true) loopsA A In Minecraft, you might have a Forever loopsA |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |