# MicroPython 101 Pre-Reader Course Collection Programming 100 Programming 300 Barbie™ You Can Be Anything™ Programming 1A Programming 1B Programming 101 Programming 102 Programming 201 Programming 202 Programming 301 Programming 302 JavaScript 101 Python 101 Web Development 101 Python 201 Drones 101 WeDo Coding Augmented Reality micro:bit 101 MicroPython 101 Life Science Physical Science Earth Science Math Social Studies English Life Science Physical Science Earth Science Math Social Studies English

This course is part of Coding/STEAM Curriculum for K-8 School

• Plan includes: 30 Courses
• Classroom/School Metrics
\$3,800 per year

### MicroPython 101

A project-based introduction to micro:bit programming using MicroPython with instructions to build 16 hands-on micro:bit projects. Request Quote

• 14 lessons
• Web
• Python
##### Course includes
• 14 lessons
• 86 activities
• Enhanced Creativity Tools
• Automatic Assessment
• Tutorials and Reviews
• Coding Puzzles
• DIY Projects
• Quizzes
• Teacher Guides
##### Prerequisites
No previous coding experience required.

## MicroPython 101 Lesson Plan

### Introduction

In this lesson, students will learn how to program a word-guessing game using their micro:bit! How to play: The player will see a word with blanks (to represent the missing letters) scroll across the micro:bit. The goal of the game is to guess which letters are missing, similar to how Hangman is played. The player can scroll through the letters by pressing the micro:bit's button A and button B. To select a letter, the player needs to press both buttons at the same time. How many tries will it take until they solve the hidden word?

Note: The char_selector() and check_char() functions are Tynker specific. If students try using these functions in Python projects beyond the MicroPython 101 course, they will not work.

### New Code

• len() : This is a function that takes a string (e.g., "tynker") and returns the length of it.
• char_selector() : This is a function that will display dialog for choosing a character (letter) and will return that character once it's selected by the user.
• check_char() : This is a function that can check if a given character is in the hidden word.

• None

### Objectives

Students will...

• Apply coding concepts to solve challenge activities
• Create a word-guessing game using the micro:bit

### Materials

• micro:bit device (recommended 1 per student)
• USB cable
• Computers, laptops, or Chromebooks (1 per student) with student account access to Tynker.com

### Warm-Up(5 minutes)

• Tell your students that they're going to create a word-guessing game today using their micro:bit. Demonstrate how to play:
• Step 1: Write a word with missing letters on the classroom board. (Example: c_ _ p _ t _ r)
• Step 2: Ask students to try guessing which letters are missing.
• Step 3: Reveal the hidden word: computer.

### Activities(45 minutes)

Facilitate as students complete all Guess the Word modules on their own:
1. Guess the Word (Document)

• Students will read a short document that introduces the lesson.
• Students will learn that they're going to create a word-guessing game using their micro:bit.
• How to play: The player will see a word with missing letters scroll across their micro:bit. They'll need to guess which letters are missing.

2. Displaying the Word (DIY)

• In this module, students will begin programming their word-guessing game. Explain that they'll continue adding onto their game in the upcoming modules.
• Step 1: Showing the Hidden Word
• To solve this challenge, students need to program their micro:bit to display their word using underscores for each hidden letter.
• Make sure they read the requirements carefully:

• Give a hint: Ask studentsâ€¦
- What should we name our first variable? (Answer: word.) After we name our first variable, what value should we assign it to? (Answer: "tynker".)
- What should we name our second variable? (Answer: shown_text.) After we name our second variable, what value should we assign it to? (Answer: "tynker".)
- We need to create a variable that holds the number of characters left to guess. What should we name it? (Answer: chars_left.) After we name our variable, what value should we assign it to? (Answer: len(word), because len() takes a string (e.g., "tynker") and returns the length of it.)

3. Letter Selector (DIY)

• Emphasize to students that single letters, digits, or symbols are called a character. Optional: Ask students, "What is 'char' short for?" (Answer: character.)
• Point out to students that they need to program their game to show the previous letter when the user presses the micro:bit's button A, and show the next letter when the user presses the micro:bit's button B. To select a letter, the user needs to press both buttons at the same time.
• Coding Challenge, Step 2: Choosing a Letter
• To solve this challenge, students need to finish the provided code to allow the player to guess a letter and check if it's part of the hidden word.
• Give a hint: Ask studentsâ€¦
- What should we name the variable? (Answer: selected_char). We need to store the return value from char_selector(), so what should we assign it to? (Answer: char_selector() ).
- What function should we use to display the selected character? (Answer: display.show() ).

4. Checking for a Character (DIY)

• Students are introduced to the check_char() function, which allows them to check if a character (letter) is part of the hidden word
• Coding Challenge, Step 3: Verifying the Character
• To solve this challenge, students need to finish the provided code and make the game check if a selected character is part of the hidden word.
• Give a hint: Ask students, "What do we need to do in order for display.scroll() to display shown_text?" (Answer: Type shown_text inside the parentheses). It should look similar to this:

5. Finishing Touches (DIY)

• Coding Challenge, Step 4: Finishing the Game
• This is the last step for the game.
• Optional: Help students get started on their loop by providing them the following code:

• Are students struggling to display a "win" message? Tell them to use a while True: loop and two display.scroll() functions. One display.scroll() function should display shown_text, and the other display.scroll() function should display the message "You Win!".

6. Guessing the Words (DIY)

• This module instructs students to experiment with their code as they test and debug their game.
• Make sure students are testing different words.
• If students finish early, ask them to try the bonus activities or show their game to a friend. How many tries did it take until someone guessed their word?

7. Review (Document)

• Students practiced working with lists by using the characters list in today's coding activities.
• Students can use len() to determine the length of a string. len() can also be used to pass an array as an argument.

8. Quiz (Multiple-choice)

• Students will be asked 5 quiz questions to review concepts from this lesson.

### Extended Activities(10 minutes)

• How can we modify our code to make the word-guessing game more challenging?
• Did anyone try the bonus tasks? How did you modify your code?
• What are some of the different words you used? Which word seemed to stump the most people?

### U.S. Standards

• CCSS-Math:MP.1
• CCSS-ELA: 6-8.RST.3, 6-8.RST.4, 6-8.RST.7
• CSTA: 2-AP-11, 2-AP-13, 2-AP-15, 2-AP-17
• CS CA: 6-8.AP.11, 6-8.AP.13, 6-8.AP.15, 6-8.AP.16, 6-8.AP.17
• ISTE: 1.c, 1.d, 4.d, 5.c, 5.d, 6.b

### U.K. Standards

Key Stage 2 (Years 4-6)

• Design, write and debug programs that accomplish specific goals, including controlling or simulating physical systems; solve problems by decomposing them into smaller parts.
• Use logical reasoning to explain how some simple algorithms work and to detect and correct errors in algorithms and programs.
• Understand computer networks, including the internet; how they can provide multiple services, such as the World Wide Web, and the opportunities they offer for communication and collaboration.
• Use technology safely, respectfully and responsibly; recognise acceptable/unacceptable behaviour; identify a range of ways to report concerns about content and contact.

Key Stage 3 (Years 7-9)

• Understand several key algorithms that reflect computational thinking [for example, ones for sorting and searching]; use logical reasoning to compare the utility of alternative algorithms for the same problem.
• Create, re-use, revise and re-purpose digital artefacts for a given audience, with attention to trustworthiness, design and usability.
• Understand a range of ways to use technology safely, respectfully, responsibly and securely, including protecting their online identity and privacy; recognise inappropriate content, contact and conduct and know how to report concerns.