AP CSP CodeX - Mission 4: Display Games (Obj. 1-7)

Mission 4 Obj 1-7 Lesson Plan

Mission 4: Display Games (Obj. 1-7)

Students learn about variable data types, convert between integers and strings, and use display.print() to display multiple messages.

โฐ 45 min ๐ŸŽฏ Grades 9-12 ๐Ÿ’ป CodeSpace ๐ŸŽฎ CodeX ๐Ÿ Python
View Lesson Outline
๐Ÿ“‹

Overview

In this lesson, students learn CodeX display basics. They show and print text messages, learn that values have different data types like integer and string, and convert between the two. Students also write code to perform a calculation. In Objective 7, they use a Boolean condition in their first if/else statement. The Mission 4 Obj 1-7 Assignment lets students take notes as they go, and the Display program (through Obj. 7) is the work to turn in.

๐ŸŽฏ Mission Goal: Students will learn about variable data types and use display.print() to display multiple messages.

๐ŸŽฏ

Learning Targets

  • I can print multiple messages on the screen.
  • I can convert between integers and strings.
  • I can identify a variable data type.
  • I can write an if:else conditional statement.
๐Ÿ’ก

Key Concepts

  • Arguments are introduced to students when calling built-in functions.
  • Students write code to perform a calculation.
  • Values have different data types, like integer and string.
  • Indenting after a colon is very important!
โœ…

Assessment Opportunities

โ˜‘๏ธ

Success Criteria

  • Define and use an argument in a function call
  • Understand and use variable types, converting types when needed
  • Use a Boolean condition in an if..then statement
๐Ÿ“

Digital Resources

๐Ÿงฐ

Classroom Materials

  • โ–ธCodeX
  • โ–ธUSB-C cable
  • โ–ธComputer
๐ŸŒ

Real-World Applications

๐ŸšฆProfessional software developers use the skills in this lesson to build traffic lights.
๐ŸŸ๏ธThey also use them to build sports event scoreboards.
๐ŸŽฎAnd they use them to build games, and more.
๐Ÿ—ฃ๏ธThis mission controls lights, displays images and text, and accepts input from the user through a button press. Discuss devices that do this in our daily lives.
๐Ÿš€

Extensions & Cross-Curricular

Lang ArtsStudents keep a daily journal, or use a reflection form, to process what they learned and write down questions they still have.
ExtensionStudents (or the class together) keep a chart of errors and the ways to fix them.
ExtensionAdd vocabulary to a word wall, and keep a document or chart of the Python code learned during each mission.
๐Ÿ”ค

Vocabulary

โ–พ
Argument - Passing data to functions (information a function uses to complete its task).
Integer - A whole number that can be positive, negative or zero.
String - A sequence of characters, like words or sentences.
Conversion function - A built-in function that converts a value to a different (and specific) data type.
Branching - Decision points in code; a condition.
Selection - Decision points in code; a condition. This term isn't in the CodeSpace documentation but is used in AP CSP.
Boolean - True or False data type (values that can be True or False).
Indentation - Structuring blocks of code in Python; statements ending with a colon (:) execute the block of code indented four spaces beneath it.
๐Ÿ

New Python Code

โ–พ
display.show("Ahoy")Display a word.
word = str(number)Convert a number to a string.
number = int(string)Convert a string to a number (integer).
display.show(str(9))
display.show(str(number))
Display a number using display.show(). It can be a literal, like 9, or a variable, like number.
display.print("Jack and Jill")
display.print("went up a hill")
display.print("to fetch a pail")
Display text on more than one line using display.print().
pressed = True
if pressed:
ย ย ย ย pixels.set(0, GREEN)
else:
ย ย ย ย pixels.set(0, RED)
If/else statement (branching). Look for the colon (:) at the end of each branch, and indent the block of code for each branch. This is very important!
๐Ÿ“

Standards

โ–พ

CSTA Standards - Grades 9-10

3A-CS-03 3A-AP-13

CSTA Standards - Grades 11-12

3B-AP-16 3B-AP-23

AP CSP Framework - Algorithms and Programming

AAP-1.B - Determine the value of a variable as a result of an assignment.
AAP-2.H - Write conditional statements. Determine the result of conditional statements.

AP CSP Framework - Computational Thinking Practices

3.A - Generalize data sources through variables.
4.C - Identify and correct errors in algorithms and programs, including error discovery through testing.
๐Ÿ“
Preparing for the Lesson
  • In advance, create a class on your dashboard and have the join code ready to give your students.
  • The assignment is best completed digitally. Prepare the assignment to give through your LMS.
  • If you have a word wall, or another form of vocabulary presentation, prepare the new terms.
  • Have the Mission Reminders slides ready to review before students start.

๐Ÿง‘โ€๐Ÿซ
Teacher Notes
  • Mission 4 may take a little over a class period, so it is divided up into two lessons.
  • If students take longer for the objectives, consider adjusting the assignment to end in one class period, even if you stop before Obj. 7. If students take less time, you can continue in Mission 4. There are additional instructions at the end of Mission 4 for creating and using functions.
  • Another suggestion for assessment is for students to keep a daily journal, or use a reflection form for students to process information they learned and reflect on questions they may still have.
  • You may consider having students (or the class collectively) keep a chart of errors and the ways to fix them.
  • You can also add vocabulary to a word wall and keep a document or chart of the Python code learned during each mission.
  • Refer to the lesson plans in the Python with CodeX Mission Pack Curriculum for additional challenges, cross curricular suggestions and additional information.
๐Ÿ—บ๏ธ

Lesson Outline

This outline gives the narration for one way to present the lesson.

๐Ÿ—ฃ๏ธWarm-up

Use a discussion strategy, like journaling, working at boards, selecting random students, or a form of think-pair-share.

Review with students the concepts from Mission 3: variables, RGB and pixels. If you have time, you could use the Mission 1, 2, 3 Kahoot Review, or something similar.

๐Ÿ’ปActivity - Mission 4 Objectives 1-7

Randomly group students into pairs for pair programming (or they can work individually).

Students log in to one computer. Two computers can be used if they want to have the activity guide open on one computer and CodeSpace on the other computer.

Teaching tip (before they start): Review the Mission Reminders slides. Students go to make.firialabs.com and should be at the beginning of Mission 4.
Teaching tip (Objective 1): The term "argument" is introduced. Students should click on the wrench to see documentation. The documentation includes positional and keyword arguments. They don't need to worry about that, only the definition at the beginning of the paragraphs. You may want to expand on the definition (see the vocabulary above) and give examples:
  • sleep(1) - argument is 1
  • sleep(delay) - argument is delay
  • pixels.set(0, color) - arguments are 0 and color
  • display.show(pics.PLANE) - argument is pics.PLANE
Teaching tip (Objective 3): Students have to add a line of code to calculate num and then use num in the display command. This is a possible source of confusion. They can use CodeTrek if they get frustrated. Also, they will get an error in their code. The instructions clearly state this, but if students are not reading the instructions they may think they are doing something wrong. Students should also read the Hint, which discusses the error they will get.
Teaching tip (Objective 5): The code is running sequentially, so only "world" shows on the screen. You may want to emphasize this word because it is used on the AP CSP Create Performance Task prompts.
Teaching tip (Objective 7): This is the first time students use a Boolean condition and if statement. The instructions suggest they use the debugger to step through the code and see what it is doing. You may want to guide them through this, or you may believe they are understanding without stepping through. More unplugged practice will be coming with if statements.

โœ… The assignment is complete and ready to turn in. Both students should include their names on the document. You can decide if you want students to turn in the program up to this point, or wait until the end of Mission 4.

๐Ÿง‘โ€๐Ÿคโ€๐Ÿง‘Wrap-Up

โœ… Important: Remind students to clear their CodeX.

Formative assessment:

  • Daily reflection journal
  • Exit ticket on data types, Boolean, or branching
  • Group review on data types, Boolean, or branching