Coding Chatbots Lesson Plans PDF

Summary

These lesson plans guide students through programming a chatbot in Python. The course focuses on creating a chatbot for a guessing game, suitable for 7th-9th graders. The lesson plans include introductions, activities, and discussions covering essential Python programming concepts.

Full Transcript

LESSON PLANS Learn Python by Programming Chatbots 1 © 2022 CodeMonkey Studios Ltd. LESSON PLANS Copyright © 2022 by CodeMonkey Studios Ltd. All rights reserved. This book or any portion thereof ma...

LESSON PLANS Learn Python by Programming Chatbots 1 © 2022 CodeMonkey Studios Ltd. LESSON PLANS Copyright © 2022 by CodeMonkey Studios Ltd. All rights reserved. This book or any portion thereof may not be reproduced or used in any manner whatsoever without the expressed written permission of the publisher. 2345 Yale St., 1st floor Palo Alto, CA 94306 [email protected] www. codemonkey.com 2 © 2022 CodeMonkey Studios Ltd. LESSON PLANS Table of Contents Introduction 4 Lesson 9 – Advanced Operators (#39-43) 97 Standards 5 Lesson 10 – Methods (#44-48) 109 121 Lesson 1 – Send & Receive (#1-4) 6 Lesson 11 - Methods – Return Value (#49-53) 132 Lesson 2 – Variables as Containers (#5-8) 17 Lesson 12 – Methods, Import (#54-58) 144 Lesson 3 – Conditional Instructions (#9-14) 27 Lesson 13 – Modulo & Booleans (#59-62) 156 Lesson 4 – Advanced Variables (#15-18) 39 Lesson 14 – elif (#63-66) 166 Lesson 5 – Repetitive Execution (#19-24) 49 Lesson 15 – Improvements – Lists and More (#67-70) 177 Lesson 6 – Lists & Classes (#25-30) 61 Lesson 16 – More elif (#71-74) 185 Lesson 7 – Game - Class (#31-34) 76 Glossary Lesson 8 – While & Boolean Operators (#35-38) 86 © 2022 CodeMonkey Studios Ltd. 3 LESSON PLANS Introduction Thank you for choosing to teach your students how to code in Python. In this course, students will code a chatbot program that will host a popular guessing game where players need to guess the correct letters in a secret word. Students will write the entire Python code by themselves. This course is recommended for 7th-9th graders. We recommend that teachers have moderate background in coding to teach this course. For students, previous coding experience is an advantage. The following 16 lesson plans will cover all 74 exercises. Each lesson is made up of 3 parts: an Introduction, Playtime and Debriefing. Each lesson is broken down to 45 minutes, however, some may take longer to complete. If you are rushed for time, please skip to part 2. At the end of this document, you will find a Glossary that summarizes each coding concept. Please refer to this throughout the course. For information regarding setting up a class, please read A Beginner’s Guide to CodeMonkey, located in the Teacher’s Resources Menu on your homepage. Please email us with any questions. Good Luck!! The CodeMonkey Team © 2022 CodeMonkey Studios Ltd. 4 TO LESSON PLANS STANDARDS *visit course page for detailed-alignment CSTA K-12 COMPUTER SCIENCE COMMON CORE STATE NATIONAL CURRICULUM IN STANDARDS ENGLAND KEY STAGE 1 CCSS.MATH.PRACTICE.MP1 Level 1/K-3/3-6 : Computational Thinking KEY STAGE 2 CCSS.MATH.PRACTICE.MP3 Level 1/K-3/3-6: Computing Practice & KEY STAGE 3 CCSS.MATH.PRACTICE.MP4 Programming KEY STAGE 4 CCSS.MATH.PRACTICE.MP5 Level 2/6-9: Computational Thinking CCSS.MATH.CONTENT.6.NS.C.5 Level 2/6-9: Collaboration CCSS.MATH.CONTENT.6.EE.B.6 Level 2/6-9: Computing Practice & CCSS.ELA-Literacy.RST.6-8.3 Programming CCSS.ELA-Literacy.RST.6-8.7 Level 2/6-9: Computers & Communication Devices Level 3A/9-12: Computational Thinking Level 3A/9-12: Collaboration Level 3B/9-12: Collaboration © 2022 CodeMonkey Studios Ltd. 5 TO LESSON PLANS Lesson 1 – Send & Receive In this lesson, students will play a game that will help them prepare for the course ahead. They will also become familiar with the Coding Chatbots environment. Please note that the minimum class time required for this lesson is 45 minutes. If you are rushed for time, please skip to Part 2. © 2022 CodeMonkey Studios Ltd. 6 TO LESSON 1: Send & Receive Objectives Students will: Write short Python code Use output (send_message) and input (read_message) Use ‘test’ when they want to run automated tests on the chatbot and ‘chat’ when they want to run their own checks. Complete exercises 1-4 © 2022 CodeMonkey Studios Ltd. 7 TO LESSON 1: Send & Receive Components Terms: input, output (see Glossary for more information) © 2022 CodeMonkey Studios Ltd. 8 TO LESSON 1: Send & Receive Part 1: 12 Minutes Introduction Activity – Play “Snowman” 5 mins. Today you will be playing Hangman, or as we will refer to it ‘Snowman’. This game will focus on aspects of chatbot interface, specifically input and output messaging. For this activity, you or a student will take on the role of the host and play Snowman with your class. The host should refrain from talking in this activity – only write on the board. Be sure to write the full interaction on the board. The word your students will need to guess is Hangman (feel free to choose another word). 1. Start this task by writing the following on the board: You have 7 tries to guess the word - “__ __ __ __ __ __ __” Who wants to go first? Play this game with your class by writing all instructions and guessed letters on the left-side of the board as shown above. If you have a longer class than 45 minutes, you can play this game a couple of times with different students acting as the host. © 2022 CodeMonkey Studios Ltd. 9 TO LESSON 1: Send & Receive Part 1: 12 Minutes Introduction Discussion 5 mins. Lead a discussion with your class about the game by asking the following questions: 1. What is on the left-side of the board? The transcript of the game. The clear depiction of instructions between the host and students. 2. Do you see a difference in the text? Questions vs. answers format. 3. Who is responsible for the output? (aka the instructions) The host or chatbot 4. Who is responsible for the input? (aka the guesses) The students or players 5. What is the game flow? A word is chosen by the host and the number of letters in the word are marked on the board. Students guess letters one at a time. The host checks to see if the letter is in the word and the guessed letters are added either to the word on the board or in a bank with other wrongly guessed words. The number of guesses left are updated. © 2022 CodeMonkey Studios Ltd. 10 TO LESSON 1: Send & Receive Part 1: 12 Minutes Introduction Cont. Discussion 2 mins. Summarize the discussion by playing the video below, which will show what students will build at the end of this course. Point out the output messages and input messages between the chatbot and player are similar to the game you just played. © 2022 CodeMonkey Studios Ltd. 11 TO LESSON 1: Send & Receive Part 2: 28 Minutes Playtime Log-in 1 min. Instruct your class on how to log into their CodeMonkey accounts and go to the Coding Chatbots activity. If your students use usernames and passwords to log-in, make sure they store their information where they can easily access them in the future. You can also handout user log-in cards. If a student forgets their password, you can reset it by visiting the classroom dashboard, going to the Students tab, and clicking on reset password. © 2022 CodeMonkey Studios Ltd. 12 TO LESSON 1: Send & Receive Part 2: 28 Minutes Playtime Cont. Explanation - Interface 9 mins. 1. Open Coding Chatbots 2. Show how the environment is divided into 3 sections: the instructions (left), the Python editor (center) and the chatbot (right). 3. Send message(“text”) displays messages in the chatbot and the text that you want to send needs to be written inside the quotation marks in order to work. Each exercise in the course includes tasks that need to be completed. 4. After making the changes required in the task, it is completed by clicking on the “check” button. 5. Upon successful completion of an exercise, a green checkmark appears and the next exercise becomes available. 6. If the changes to the code are incorrect, the task is marked as “failed” and a retry is needed. 7. Use the example in exercise #1 to explain how to use the editor, check and chat buttons, and send_message(“text”). 8. Ask your students to change the text as required in the exercise. Then, they need to hit check and hit chat. 9. **Make sure the text in the send_message is identical to the text required in the instructions.** 10. The final task in each exercise is to run your chatbot. 11. Ask your students to: Change the text in the editor as required in exercise #1 Click CHECK Click CHAT to run their program © 2022 CodeMonkey Studios Ltd. 13 TO LESSON 1: Send & Receive Part 2: 28 Minutes Playtime Cont. Playtime 5 mins. Have your class complete exercises 1 and 2. Encourage them to go step by step. Make sure they use the same exact text required by the exercise or else it will not pass. Explanation 4 mins. Let's learn how to chat - Ask your class what defines a chat/conversation? Question & Answer Request & Response In this game, instead of a question and answer to conduct a conversation, we will use send_message(“text”) and read_message() read_message() allows you to write your responses to questions in the bottom half of the chatbot Present the first instruction of exercise 3. For more information on read and send message, please refer to the Glossary. © 2022 CodeMonkey Studios Ltd. 14 TO LESSON 1: Send & Receive Part 2: 28 Minutes Playtime Cont. Playtime 5 mins. Have students complete exercise 3. You can use your classroom dashboard to keep track of student progress. Explanation 4 mins. In exercise #4 we will learn the difference between TEST and CHAT. Please explain the following: TEST is an internal checking mechanism that causes the messages to be sent. When a read_message is reached in the code, an automatic response is given to the chatbot. The user does not need to enter anything. o Use Test mode to check the code’s compliance with the game instructions CHAT is a Python compiler that causes the messages to be sent. When a read_message is reached in the code, the execution is halted, and the chatbot waits for the user to respond. Once the user responds, the chatbot continues running. o Use chat mode to give additional examples that are not included in the game. © 2022 CodeMonkey Studios Ltd. 15 TO LESSON 1: Send & Receive Part 3: 5 Minutes Debriefing Discussion 5 mins. Ask your class to name something they learned today. Remind them of the following: 1. The Coding Chatbots environment: CHECK TEST CHAT 2. The methods: send_message(“text”) read_message() 3. Ask what happens if the text in the send_message(“”) is not identical to the instructions? The task will not pass 4. Ask what happens if no one replies back to a read_message()? The code will not run until a response is entered © 2022 CodeMonkey Studios Ltd. 16 TO LESSON PLANS Lesson 2 – Variables as Containers This lesson focuses on how and when to use variables. Please note that the minimum class time required for this lesson is 45 minutes. If you are rushed for time, please skip to Part 2. © 2022 CodeMonkey Studios Ltd. 17 TO LESSON 2: Variables as Containers Objectives Students will: Create situations that require using variables Define and assign variables Use variables in the context of send/read methods Understand the difference between a variable’s name and its value Concatenate variables into strings Complete exercises 5-8 © 2022 CodeMonkey Studios Ltd. 18 TO LESSON 2: Variables as Containers Components Terms: Variable, String (see Glossary for more information) © 2022 CodeMonkey Studios Ltd. 19 TO LESSON 2: Variables as Containers Part 1: 20 Minutes Introduction Activity - Variables 10 min. Today’s lesson will start with an interactive activity that will illustrate how variables and containers work. Please prepare the following in advance: 3 envelopes marked A, B & C (envelopes will represent the containers/variables) 10 index cards numbered 1-10 and a blank index card if needed later on (these numbers will represent the values) Call on 3 volunteers to the front of the room. They will represent the program we are coding. Place the 3 envelopes and the index cards on a desk. Explain that the envelopes will play the role of containers and the index cards will represent the values. Ask the volunteers to each choose an index card. Ask 2 of the volunteers to put their card in an envelope.. Then, ask the 3rd volunteer to put their card in one of the full envelopes. Ask the class what will happen to the value that already exists? Can we have 2 values in one envelope? Can a container or variable hold two values? (Answer is no, a container or variable can only hold one value at a time) The student should takeout the index card that the previous volunteer put and put his or her own index card in the envelope. This is when you emphasize that a variable can only hold a single value at a time. If you took out a value, you cannot recall it. Then ask the class, what is in the empty envelope? They may answer zero. The answer is that the envelope’s value is nothing, which is not the same as 0. © 2022 CodeMonkey Studios Ltd. 20 TO LESSON 2: Variables as Containers Part 1: 20 Minutes Introduction Cont. Activity – Variables Cont. 10 min. Now, we will assign a value to the empty envelope using the index cards in the existing envelopes. For example, if envelope A had the number 8 in it and envelope B had the number 4 in it, we will now assign envelope C the value 12. So take a blank index card, write 12 on it, and place it inside envelope C. Write on the board C = A +B. Ask how do we read it? What does it mean? Some will say will say C equals A + B, however this is not how we read it in programming. In programming, it is an assignment or placement (When you place the value into the container.) So in programming, it is read as A + B is placed into C. Mention to the class that the container (envelope) must always stay on the left-side of the equation. The value (index card) is always on the right-side. So that is why we can say it is not like an equation since in programming, 3 = C is not the same as C = 3). To further illustrate this, change the value of one of the previously full envelopes and ask what happens now? Will the value in the previously empty envelope change as well? The answer is no. © 2022 CodeMonkey Studios Ltd. 21 TO LESSON 2: Variables as Containers Part 1: 20 Minutes Introduction Cont. Discussion 5 mins. Ask the students the following: 1. How would you define a variable? Variables hold values - numbers, text (and more) 2. Does a variable have a name? Yes, the programmer can choose a meaningful name 3. What happens when you assign a new value to a variable? You destroy anything that was previously there 4. How do you refer to a variable? By it’s name *Do not confuse variable names with their values © 2022 CodeMonkey Studios Ltd. 22 TO LESSON 2: Variables as Containers Part 1: 20 Minutes Introduction Cont. Common Misconceptions about Variables 5 mins. Point out for the following common misconceptions: Variables in programming are similar to variables in Math (students get these confused – they are not the same) Assignment is like a mathematical equation – both sides are equal and can therefore be switched (No, the right hand value gets assigned to the left hand value so they can not be switched) A variable still holds its original value after an assignment (No, after an assignment, the original value gets replaced by the new one) A sequence of assignments all happen together at the same time and can happen in any order (False, a sequence happens from top to bottom and order is important) After an assignment, any future change to one variable changes the other (false: the connection between 2 variables is not a binding relationship for ever) © 2022 CodeMonkey Studios Ltd. 23 TO LESSON 2: Variables as Containers Part 2: 20 Minutes Playtime Explanation 7 mins. Go to exercise 5 in Coding Chatbots. Edit the following code: language = "Python" send_message("I speak") send_message(language) Before you click CHAT, ask the class what will happen in the chat? Here the player has no role. Click CHAT Add the following instructions send_message("What do language you speak") language=read_message() send_message(language) send_message("is important to know") Before you click CHAT, ask the class what is the difference from the first 3 instructions. Here the use of read_message() halts the game until the player responds. Click CHAT © 2022 CodeMonkey Studios Ltd. 24 TO LESSON 2: Variables as Containers Part 2: 20 Minutes Playtime Cont. Log-in 1 mins. Review log-in instructions here. Playtime 22 mins. Ask students to complete exercises 5-8. Encourage them to go step by step. Pay attention to use the exact text required in the exercise. © 2022 CodeMonkey Studios Ltd. 25 TO LESSON 2: Variables as Containers Part 3: 5 Minutes Debriefing Discussion 5 mins. Ask your class to come up with one thing they learned today, leading questions could be: 1. What did we use the envelope for? Stand as variable 2. What type of values can we assign to a variable? Numeric, string, letters 3. What happens when we change the value of the variable? It changes from that moment on, you cannot recall the old value if you didn’t save it somewhere else 4. How can we assign a value from the user? read_message() 5. What is the difference between variable name and its value? The name is the way we refer to the variable and it does not change. The value can change 6. What are variables good for? To store data. If you delete it, variables hold all the data we use. And we can go back to this data to use it as we compute. © 2022 CodeMonkey Studios Ltd. 26 TO LESSON PLANS Lesson 3 – Conditional Instructions The lesson will start with a short interactive guessing game like in the first class, except this time it will focus on defining conditional statements. The main part of the lesson is aimed at practicing the use of conditional statements including: in operator if/else Please note that the minimum class time required for this lesson is 45 minutes. If you are rushed for time, please skip to Part 2. © 2022 CodeMonkey Studios Ltd. 27 TO LESSON 3: Conditional Instructions Objectives Students will: Learn conditional execution Define a situation when a part of the program should run or not Know how to use the ‘in’ operator Get a glimpse into Boolean values – True and False Understand the difference between if and else Complete exercises 9-14 © 2022 CodeMonkey Studios Ltd. 28 TO LESSON 3: Conditional Instructions Components Terms: Boolean value (in), true & false, conditionals (if and else), Boolean expression View Glossary for more information © 2022 CodeMonkey Studios Ltd. 29 TO LESSON 3: Conditional Instructions Part 1: 10 Minutes Introduction Activity – Conditional ‘Snowman’ 5 mins. Choose a student to play the host and have them choose a word that is 5-7 letters long. The host should draw dashes on the board to match the length of the word. To guess the word, students can only ask true or false statements such as is the letter X is in the word and the host can only answer with either true or false. The host will draw parts of a snowman each time students guess wrong. Students will play until the word was guessed or the snowman was drawn. Make sure the host only answers when the question is phrased as defined above. By asking is blank letter in the word , students are practicing a condition statement in Python. True or false is the only answer of this statement in Python. © 2022 CodeMonkey Studios Ltd. 30 TO LESSON 3: Conditional Instructions Part 1: 10 Minutes Introduction Cont. Discussion 5 mins. Ask your students what was unique about the game this time (the students can only ask questions in a certain way like in the programming language python) ○ What was unique about the question they asked - Can a letter be in and not-in the word at the same time? Can true and false exists at the same? No, a single condition can only either be true or false ○ Discuss the fact that there is only one valid answer Present the concept of true and false: ○ True and False are Boolean values used for making decisions. ○ There are different ways of comparing values - We can test if a character exists in a string or if a number is greater/smaller than another number, if they are equal or if they are different. ○ In each case, the value of expression is true or false. © 2022 CodeMonkey Studios Ltd. 31 TO LESSON 3: Conditional Instructions Part 2: 35 Minutes Playtime Explanation – in 5 mins. Write the following on the board: (Ask students to reply back with true or false) "P" in "Python" "on" in "Python" "a" in "Python" “p” in “Python” → note that Python is case sensitive Introduce the in operator for strings, which is used to test whether a value is found within a sequence Complete exercise 9 with the class Ask your students how they can use the ‘in’ operator They can use it in send_message and read_message (as practiced the first lesson) Ask your class what the result of running send_message(“Py" in "Python") will be They will see true written in the chatbot Using variables within the ‘in’ operator, present the following: response = read_message() #response will get the user’s response or it can be a symbol send_message(response in “Python”) #this will check if the letter is in “Python” © 2022 CodeMonkey Studios Ltd. 32 TO LESSON 3: Conditional Instructions Part 2: 5 Minutes Playtime Explanation – if 5 mins. Conditional checks are important for comparing numeric values What will the output be? if 7 > 0: send_message("7 is greater than 0") And in this case - if -7 > 0: send_message("7 is greater than 0") It is important to emphasize that if the condition is false, then the instructions under the if are not executed at all Pay attention that each if starts at the beginning of the line At the end of the ‘ if’ you always need to use ‘:’ Make sure the instructions within the ‘if’ are indented one tab © 2022 CodeMonkey Studios Ltd. 33 TO LESSON 3: Conditional Instructions Part 2: 5 Minutes Playtime Explanation – else 5 mins. How can we define a different set of instructions if the condition is false? An if statement can be followed by an else statement. if "x" in "Python": send_message("x is in Python, really??") else: send_message("x is not in Python") Complete exercise 11 Pay attention that each else starts at the beginning of the line At the end of ‘else’ you always need to use ‘:’ Make sure the instructions within the ‘else’ are indented one tab 1. Present the following on the board and ask your to write the output of each code 2. Discuss the difference between the code on the left and the code on the right © 2022 CodeMonkey Studios Ltd. 34 TO LESSON 3: Conditional Instructions Part 2: 5 Minutes Playtime Log-in 1 mins. View log-in instructions here. Playtime 20 mins. Have students to complete exercises 9 through 14 Ex. 9-11 covers each of the topics presented in the lesson Ex. 12-14 integrates the new material into the game using variables, send and read instructions. Encourage the students to go step by step. Pay attention to use the exact text as required in the exercise Tip: use your classroom dashboard to keep track of student achievements © 2022 CodeMonkey Studios Ltd. 35 TO LESSON 3: Conditional Instructions Part 3: 5 Minutes Debriefing Debriefing 5 mins. Ask students to come up with a situation in real life where they use conditions: Conditions are everywhere even if we don't explicitly notice A condition can either be True or False, but never both For example, if it rains tomorrow, we will not have school. © 2022 CodeMonkey Studios Ltd. 36 TO LESSON PLANS Lesson 4 – Advanced Variables The main part of the lesson is aimed at practicing the life-cycle of variables - declaring, initializing, assigning and changing variables. In addition, students will practice the fundamental string and arithmetic operators for concatenating strings and adding values using = and +=. Variables are like boxes that you can use to store pieces of information for your program! Please note that the minimum class time required for this lesson is 45 minutes. If you are rushed for time, please skip to Part 2. © 2022 CodeMonkey Studios Ltd. 37 TO LESSON 4: Advanced Variables Objectives Students will: Gain a deeper understanding of the concept of variables Learn how to initialize and change the the value of a variable Have an advanced understanding of variables: get to know the difference between number and sting variables and how to use them in Python Concatenate string Arithmetic operators like /+=/-+ Complete exercises 15-18 © 2022 CodeMonkey Studios Ltd. 38 TO LESSON 4: Advanced Variables Components Terms: Variables See Glossary for more information © 2022 CodeMonkey Studios Ltd. 39 TO LESSON 4: Advanced Variables Part 1: 5 Minutes Introduction Activity – Cups 5 min. We will demonstrate what swapping values means through the representation of different beverages in cups. In this activity, you need 3 glasses, 2 containing different-colored drinks (i.e. orange juice and water). Ask the class how you can switch between the two liquids? Answer: use the third empty cup. This is a metaphor for swapping values contained in variables. In order to swap variables, we need to use a third temporary variable. © 2022 CodeMonkey Studios Ltd. 40 TO LESSON 4: Advanced Variables Part 1: 5 Minutes Introduction Cont. Activity - Advanced 5 mins. If the class is familiar with variables swap with using a temp variable, present the following code: Ask the class what will be the output and go line by line to follow the code and variables values var_1 = 5 var_2 = 7 var_1 = var_2 + var_1 var_2= var_1 - var_2 var_1 = var_1 - var_2 send_message(var_1) send_message(var_2) © 2022 CodeMonkey Studios Ltd. 41 TO LESSON 4: Advanced Variables Part 2: 35 Minutes Playtime Explanation 7 mins. This part correlates to exercise 15. Variable value can change along the program Assigning new value my_var = "snowman” my_var = "Python” Assigning value from input my_var=read_message() Assigning value from input or programmer-defined can be done in any place in the code Once the value has changed the previous value no longer exist © 2022 CodeMonkey Studios Ltd. 42 TO LESSON 4: Advanced Variables Part 2: 35 Minutes Playtime Cont. Explanation – Concatenate 5 mins. Concatenate: to link strings and characters together in a chain or series Strings can be changed by adding additional characters to an existing string The + operator concatenates two strings Ask the class what will be the value of the variable ‘name’ after each of the following instructions? name = "Pyth" letter_1 = "o" letter_2 = "n" name = name + letter_1 name += letter_2 Emphasize the ability to use the long and short versions of the concatenate operator as presented in this example. © 2022 CodeMonkey Studios Ltd. 43 TO LESSON 4: Advanced Variables Part 2: 35 Minutes Playtime Cont. Explanation – Numeric Variable 5 mins. Numeric variables in Python are used to store numbers as integers or floating (rational) numbers. Variables can hold a single value of a single type at a time my_var_1 = 5 #number my_var_2 = "5" #string The arithmetic operators in Python are used to perform mathematical operations such as addition, subtraction, multiplication, and division. In this lesson we will focus on addition and subtraction. What will the output be? my_var = 0 # holds 0 my_var = 3 # holds 3 my_var += 1 # holds 4 my_var -= 2 # holds 2 my_var_1 += 75 # holds 80 my_var_2 += "75" # holds "575” Emphasize the ability to use the long and short versions of the concatenate operator as presented in the example above. © 2022 CodeMonkey Studios Ltd. 44 TO LESSON 4: Advanced Variables Part 2: 35 Minutes Playtime Cont. Log-in 1 mins. Review log-in instructions here. Playtime 20 mins. Ask students to complete exercises 15 - 18. Encourage them to go step by step. Make sure they use the exact text required in the exercise. Use your classroom’s dashboard to keep track of students’ achievements. © 2022 CodeMonkey Studios Ltd. 45 TO LESSON 4: Advanced Variables Part 3: 5 Minutes Debriefing Debriefing - Variables 5 mins. Variables hold values, the actual data that is being stored in memory Variables have names so programmers and the computer know which variable is called on Do not confuse variable names with their values A variable can only store one value of one type at a time When you change the value (or the type) in a variable, you destroy anything that was previously there © 2022 CodeMonkey Studios Ltd. 46 TO LESSON PLANS Lesson 5 – Repetitive Execution The first part of this lesson will focus on introducing the students the range() function. Then we will dive into the For loop structure using range(). Please note that the minimum class time required for this lesson is 45 minutes. If you are rushed for time, please skip to Part 2. © 2022 CodeMonkey Studios Ltd. 47 TO LESSON 5: Repetitive Execution Objectives Students will: Understand the importance of loops (that it is more efficient for the programmer than writing repetitive code) Identify repetitive code and convert a series of multiple repetitive actions into a loop Learn how to use the range() function and For loops Learn how to use len(string) Complete exercises 19-24 © 2022 CodeMonkey Studios Ltd. 48 TO LESSON 5: Repetitive Execution Components Terms: range(), for loop, len(string) See Glossary for more information. © 2022 CodeMonkey Studios Ltd. 49 TO LESSON 5: Repetitive Execution Part 1: 5 Minutes Introduction Activity 5 mins. Start with a recap of the previous lesson by presenting the code that was created in exercise 18 and asking students if they have any ideas on how to improve the code. (The code repeats 3 times, so use a loop) Present the code in exercise 19 (the code that was developed as part of exercise 18) Ask students to find ways to simplify the code (If they need more clues ask them to come up with shorter ways to design the code) Make sure students understand the notion of “repeating” code © 2022 CodeMonkey Studios Ltd. 50 TO LESSON 5: Repetitive Execution Part 1: 5 Minutes Introduction Cont. Discussion 5 mins. In the previous lessons we dealt with sequential programs and conditions. Oftentimes a program needs to repeat some blocks of code several times, so it is useful to use a loop. Ask students to identify a loop or repeating scenario in our game. Guessing letters (players will keep guessing until they guessed all the letters or ran out of tries) To keep a computer working, we need repetition or to loop back over the same block of code again and again Ask the students what we need to define in order to run in a loop Number of iterations When to stop At this point, present only the concept and need for loops, you will go into the actual use of For loops later on in the lesson © 2022 CodeMonkey Studios Ltd. 51 TO LESSON 5: Repetitive Execution Part 2: 35 Minutes Playtime Explanation – range() 5 mins. The following explanation relate to exercises 19 - 20. Introduce the range() function range() is a function that can get up to 3 parameters and it always returns a sequence of numbers range(num) returns a sequence starting from a default 0 with increments of 1 and up to num-1 For example, range(5) = 0,1,2,3,4 range(start, stop) has a default increment of 1. It starts from the value of start and ends at the value of stop minus one. range(3,8) = 3,4,5,6,7 range(start, stop, increment) has no default value. The sequence starts with the start value and ends with the last value that should be in the sequence but is less than the stop value. The difference between all consecutive numbers in the sequence is the increment. Example, range (3,8,2) = 3,5,7 © 2022 CodeMonkey Studios Ltd. 52 TO LESSON 5: Repetitive Execution Part 2: 35 Minutes Playtime Cont. Explanation – range() cont. 5 mins. Ask students to write down the sequence: range(5) → 0, 1, 2, 3, 4 Ask students to write down the call that will return the sequence 5, 6, 7, 8→ range(5,9) Ask the students to the write down the sequence: range(3,9,2) → 3, 5, 7 A range() function can also return an empty sequence - ask students to think of an example range(-5) © 2022 CodeMonkey Studios Ltd. 53 TO LESSON 5: Repetitive Execution Part 2: 35 Minutes Playtime Cont. Explanation – For 5 mins. A for loop is used for iterating over a sequence A sequence could vary using numbers and strings Using for loops, we can execute a set of statements, once for each item in a list Each execution is called an iteration To loop through a set of code a specified number of times, we can use the range() function For example, ask students to write down the output of the following code: for index in range(4): send_message(index) It is very useful to draw on the board a table to follow up on the code: index in range() output 0 yes 0 1 yes 1 2 yes 2 3 yes 3 4 no © 2022 CodeMonkey Studios Ltd. 54 TO LESSON 5: Repetitive Execution Part 2: 35 Minutes Playtime Cont. Explanation – let() 3 mins. How many guess will we let the player have? The same guesses as the number of letters in the word How can we count the number of letters in the word? Using the len() function returns the number of characters (length) in a string What will be the output of the following? send_message(len("Python")): The returned value of len() can be stored in a variable: Ask - What will be the result of running the following instruction? guessed_word = " ” word=”game” word_len = len(word) for index in range(word_len): guessed_word += "_ " © 2022 CodeMonkey Studios Ltd. 55 TO LESSON 5: Repetitive Execution Part 2: 35 Minutes Playtime Cont. Explanation – str() 2 mins. Concatenating a string and an integer is not possible. The function str() gets a number value as a parameter and returns its representation as a string. my_var = 100 send_message("Fails " + my_var + "%!") # Gives an error send_message("Passes - " + str(my_var) + "%!") # will display: # Passes - 100%! © 2022 CodeMonkey Studios Ltd. 56 TO LESSON 5: Repetitive Execution Part 2: 35 Minutes Playtime Cont. Log-in 1 mins. Review log-in instructions here. Playtime 25 mins. Have your class complete exercises 19 - 24. Encourage the students to go step by step. Pay attention to use the exact text as required in the exercise. Use your classroom’s dashboard to keep track of student achievements. © 2022 CodeMonkey Studios Ltd. 57 TO LESSON 5: Repetitive Execution Part 3: 5 Minutes Debriefing Debriefing 5 mins. Ask your class what the main topic of the lesson was: Loops, repeated execution For loops What are loops good for? Can students think of something from their daily life that is loop based? Some examples: brushing your teeth (you brush all your teeth one by one), filling a water bottle until it is full (until loop) or eating a meal (you take bit after bite) To build the loop, we used additional built-in Python functions. Which functions were used and for what purpose? Range – to define how many times the loop will occur Len – the length of the string that we go over its letters Str – Transferring an integer value into a string © 2022 CodeMonkey Studios Ltd. 58 TO LESSON PLANS Lesson 6 – Lists & Classes This lesson is divided into 2 sections, the first part will introduce Lists and the second part will deal with building the game’s Class. Please note that the minimum class time required for this lesson is 45 minutes. If you are rushed for time, please skip to Part 2. © 2022 CodeMonkey Studios Ltd. 59 TO LESSON 6: Lists & Classes Objectives Students will: Understand the concept of lists and what they are used for Manage lists Holding multiple variables and values in one place Access each value in the list Add items to a list Complete exercises 25-30 © 2022 CodeMonkey Studios Ltd. 60 TO LESSON 6: Lists & Classes Components Terms: lists, class, conditionals View Glossary for more information. © 2022 CodeMonkey Studios Ltd. 61 TO LESSON 6: Lists & Classes Part 1: 5 Minutes Introduction Activity 4 mins. Challenge your students by asking them: What if we want to save all the guessed letters during the game? Ask students to think of a way to save all the guessed letters. What do you think they will say to do if we have… 4 letters? You need 4 variables 10 letters? 10 variables 100 letters? Oh no, what can we do? The answer will be a list and add the values. Can we use different variables to store them? While 4 or 10 can still be reasonable, 100 values require something else. This is where lists come in handy! Please note: lists are known as arrays in most programming languages © 2022 CodeMonkey Studios Ltd. 62 TO LESSON 6: Lists & Classes Part 2: 35 Minutes Playtime Explanation - lists 4 mins. *Playtime can be done in parallel to the explanation Refer to exercise 25 A list is a collection of variables which is ordered and changeable To define a list: my_list = [] # an empty list my_list = ["a", "b"] #a list of two elements To collect the guessed letters, we will use the Python append() function that adds an element to the end of the list my_list.append("c") #adds "c" to the list send_message(my_list) #display: a,b,c A useful real-life metaphor for lists are school lockers because they are ordered, the values can be changed and lockers can be added or removed when needed. © 2022 CodeMonkey Studios Ltd. 63 TO LESSON 6: Lists & Classes Part 2: 35 Minutes Playtime Cont. Explanation – Lists (2) 5 mins. Refer to exercise 26 The elements in the list are ordered/indexed sequentially starting from zero. my_list = ["a", "b", "c"] send_message(my_list) #display: a send_message(my_list) #display: b Ask students if the list has 4 items within it, what will be the index of the list item in the list? It will be 2. Lists hold values. Like in a building with a lot of apartments, there are numbers per apartment. © 2022 CodeMonkey Studios Ltd. 64 TO LESSON 6: Lists & Classes Part 2: 35 Minutes Playtime Cont. Explanation – int() 2 mins. Refer to exercise 26 str() allows us to transform a numeric value into a string Ask your class what happens if we have a string that represent a number and we wish to use it as a number? The int() method returns an integer object from any number or string - int() gets a string and if it represents a number, it returns its value as a number my_string = "4" my_number = int(my_string) my_number += my_number send_message( str(my_number) ) #display: 8 © 2022 CodeMonkey Studios Ltd. 65 TO LESSON 6: Lists & Classes Part 2: 35 Minutes Playtime Cont. Log-in 1 mins. Review log-in instructions here. Playtime 8 mins. Ask the student to complete exercises 25 and 26 related to lists. Playtime can be done in parallel to the explanation Use the classroom dashboard to keep track of students’ achievements. © 2022 CodeMonkey Studios Ltd. 66 TO LESSON 6: Lists & Classes Part 2: 35 Minutes Playtime Cont. Explanation – Classes 10 mins. Our world cannot be represented with only simple variable types like strings or integers. Programming languages allow us to define more realistic types to represent the world we live in through classes. An example of a class in the real world is a form. There are many fields to fill out in the form (i.e. date, name, etc.). The blank form is a class definition. After you fill out the form, it becomes an object or instance. Instance − An individual representation of a certain class. © 2022 CodeMonkey Studios Ltd. 67 TO LESSON 6: Lists & Classes Part 2: 35 Minutes Playtime Cont. Explanation: Classes – Example 1 10 mins. This section corresponds with exercises 27-29 The first line of the class is the name of the class The class Clock has 2 attributes - hours and minutes The first method __init__() is a special method, which is called class constructor or initialization method that Python calls when you create a new instance of this class Initial values of the Clock-object attributes are defined in the init method - every new clock object created from the class clock will have the hours set to 12 and minutes set to 30 class Clock: def __init__(self): self.hours = 12 self.minutes = 30 Refer to the current instance of the class © 2022 CodeMonkey Studios Ltd. 68 TO LESSON 6: Lists & Classes Part 2: 35 Minutes Playtime Cont. Explanation – Create Object 10 mins. Exercises 27-29 The creation of the object is done outside of the class section my_clock is the object name Clock is the class To access the attributes of an object we will use the object_name.attribute - (dot operator) The dot operator is the connection between an object and one of its attributes or methods (functions). For example: my_clock.hours For example: my_clock.tick my_clock = Clock() send_message(str(my_clock.hours) + ":" +str(my_clock.minutes)) # display 12:30 © 2022 CodeMonkey Studios Ltd. 69 TO LESSON 6: Lists & Classes Part 2: 35 Minutes Playtime Cont. Explanation – Classes – example 2 10 mins. Exercises 27-29 Initial values for an object's properties can be passed to the __init__(self) method. class Clock: def __init__(self, hours, minutes): self.hours = hours self.minutes = minutes © 2022 CodeMonkey Studios Ltd. 70 TO LESSON 6: Lists & Classes Part 2: 35 Minutes Playtime Cont. Explanation – Create Object 2 10 mins. This section correlates with exercises 27-29 We created 2 clock objects - clock_1 and clock_2 - each has different values clock_1 = Clock(14,45) clock_2 = Clock(12,10) © 2022 CodeMonkey Studios Ltd. 71 TO LESSON 6: Lists & Classes Part 2: 35 Minutes Playtime Cont. Playtime 10 mins. Have the class complete exercises 27 through 30 Go over ex. 27-29 with the 2 examples of clock and team and focus on ex #30 where the students has to build the game class with 2 attributes – Word to be guessed Letters guessed Use your classroom’s dashboard to keep track of students’ achievements. © 2022 CodeMonkey Studios Ltd. 72 TO LESSON 6: Lists & Classes Part 3: 5 Minutes Debriefing Debriefing 5 mins. Summarize the lesson with recap of the 2 topics covered: Lists Classes & Objects Python is an object oriented programming language - Almost everything in Python is an object, with its properties and methods. A Class is a template for creating objects. An object is an item of the same type. A class is a definition of what features a clock, or any other object of that class, should have. A class for clock is hours, minutes and seconds and then we created different clock objects and each was initiated for a different time. It is important to mention that this is only the first time you touch the topics and the next lessons will include further exercises related to these important topics © 2022 CodeMonkey Studios Ltd. 73 TO LESSON PLANS Lesson 7 – Game - Class This lesson will cover class methods. Please note that the minimum class time required for this lesson is 45 minutes. If you are rushed for time, please skip to Part 2. © 2022 CodeMonkey Studios Ltd. 74 TO LESSON 7: Game - Class Objectives Students will: Understand the concept of class methods and will learn how to define methods within a class Practice the use of for loops with strings Complete exercises 31-34 © 2022 CodeMonkey Studios Ltd. 75 TO LESSON 7: Game - Class Components Terms: Class Methods View Glossary for more information. © 2022 CodeMonkey Studios Ltd. 76 TO LESSON 7: Game - Class Part 1: 5 Minutes Introduction Activity 4 mins. Defining attributes for a class is only the first step, in order to manage the entire life cycle of the object created from the class, we need to have a set of methods to set, present, and manipulate the object. Classes can also contain methods. Methods in classes are functions that belongs to the object and can run when they are executed on a specific object. Ask students to suggest methods that should be part of the class clock Set the time Show the time tick() Tip: If students have a hard time understanding the concepts of classes and objects, let them define their own idea for a class with attributes and methods and create objects from the class. © 2022 CodeMonkey Studios Ltd. 77 TO LESSON 7: Game - Class Part 2: 35 Minutes Playtime Explanation – Class Method 4 mins. Exercise 31 Define together with the students the method tick() within the class Clock class Clock: def __init__(self, hours, minutes): self.hours = hours self.minutes = minutes def tick(self): self.minutes += 1 if self.minutes > 59: self.minutes = 0 self.hours += 1 if self.hours > 23: self.hours = 0 Remember to add def in the beginning and a colon : at the end. Make sure the code you add is indented one tab. © 2022 CodeMonkey Studios Ltd. 78 TO P LESSON 7: Game - Class Part 2: 35 Minutes Playtime Cont. Explanation – Using a Method 5 mins. Ask what is the value of clock and what will be presented? clock = Clock(13, 23) send_message(str(clock.hours) + ":" +str(clock.minutes)) # display: 13:23 (1:23 is the value) clock.tick() send_message(str(clock.hours) + ":" +str(clock.minutes)) # display: 13:24 (1:24 is the value) © 2022 CodeMonkey Studios Ltd. 79 TO LESSON 7: Game - Class Part 2: 35 Minutes Playtime Cont. Explanation – Append() 2 mins. append() is a list method that allows us to add an item to the end of the list my_list=[”a”, “b”] my_list.append(“c”) send_message(my_list) # display [“a”, “b”, “c”] In order to build a list of the guessed letters, we will add each letter to the self.guessed_letters list by using the following instruction: self.guessed_letters.append(guess) © 2022 CodeMonkey Studios Ltd. 80 TO LESSON 7: Game - Class Part 2: 35 Minutes Playtime Cont. Explanation – For on String 5 mins. Exercise 33 When we introduced the for loop we mentioned that it can also iterate over a sequence of characters - A string is a sequence of characters. for char in "Python": send_message(char) # display P y t h o n Using for on string gives us the ability to go over the string and check each and every character, it will be very useful for the game © 2022 CodeMonkey Studios Ltd. 81 TO LESSON 7: Game - Class Part 2: 35 Minutes Playtime Cont. Log-in 1 mins. Review log-in instructions here. Playtime 23 mins. Ask the student to complete exercises 31 through 34. In exercise 34 pay attention to the nested loops - it is not recommended to focus on the topic at this point, however, for students who have previous background this could be an option for deepen their understanding on how nested loops works Use your classroom’s dashboard to keep track of students’ achievements. © 2022 CodeMonkey Studios Ltd. 82 TO LESSON 7: Game - Class Part 3: 5 Minutes Debriefing Debriefing 5 mins. Summarize the lesson with a discussion on the definition of class methods This is a good point in time to draw attention to the fact that many of the functions they are using today on string and on lists are basically classes methods © 2022 CodeMonkey Studios Ltd. 83 TO LESSON PLANS Lesson 8 – While & Boolean Operators This lesson will cover how to use Boolean Operators. Please note that the minimum class time required for this lesson is 45 minutes. If you are rushed for time, please skip to Part 2. © 2022 CodeMonkey Studios Ltd. 84 TO LESSON 8: While & Boolean Operators Objectives Students will: Know how to user additional Boolean operators - ==,!= Understand the need and structure of the while loop Complete exercises 35-38 © 2022 CodeMonkey Studios Ltd. 85 TO LESSON 8: While & Boolean Operators Components Terms: Boolean operators View Glossary for more information © 2022 CodeMonkey Studios Ltd. 86 TO LESSON 8: While & Boolean Operators Part 1: 5 Minutes Introduction Introduction – Code Review 5 min. Today students will perform a peer-assessed code review. Ask students to think about the game and the way it was built like a product life-cycle in a high-tech company. In high tech, you design something, then you do a code review, a process to check the quality and design of the software. Today you will do this. Ask students what are limitations of the game we designed it so far? Lead the students to think about the number of guesses allowed. The limitation is that you cannot guess an infinite amount of times. At this point, the number of guesses is preset. Is there a way we can change this situation? Can we do it with the for loop? © 2022 CodeMonkey Studios Ltd. 87 TO LESSON 8: While & Boolean Operators Part 2: 35 Minutes Playtime Discussion 4 mins. The while loop is a control flow statement that allows code to be executed repeatedly based on a given Boolean condition. The while loop requires relevant variables to be ready. Usually the value is changed during the loop statements. © 2022 CodeMonkey Studios Ltd. 88 TO LESSON 8: While & Boolean Operators Part 2: 35 Minutes Playtime Cont. Explanation – Comparison Operators 5 mins. The following corresponds with exercises 35-38 Before we go into while loops, we need to learn how to create conditional statements Comparison operators are used to compare two values, this lesson we will focus on 2 operators: Operator Name Example == Equal - compares the values on both of its sides. The comparison's result is: x==y True - if both values are exactly the same or False - otherwise != Not Equal - used to check if values are not equal. x!=y The comparison result is: True - if values are not exactly the same or False - otherwise (the values are exactly the same) © 2022 CodeMonkey Studios Ltd. 89 TO LESSON 8: While & Boolean Operators Part 2: 35 Minutes Playtime Cont. Explanation – Comparison Operators Cont. 5 mins. Ask students which other comparison operators they can think of Mention greater than/smaller than if "Python" != "nohtyP": send_message("not the same string") else: send_message("strings are equal") © 2022 CodeMonkey Studios Ltd. 90 TO LESSON 8: While & Boolean Operators Part 2: 35 Minutes Playtime Cont. Explanation – While 5 mins. The while loop is used when we can not determine the exact number of loop iterations in advance While loops repeat the sequence of actions many times until its condition value is False The condition is given before the loop body and is checked before each execution of the loop body In For loop, we always have the number of iterations, even if it is a parameter that we do not know its value in advance © 2022 CodeMonkey Studios Ltd. 91 TO LESSON 8: While & Boolean Operators Part 2: 35 Minutes Playtime Cont. Explanation – While Cont. 5 mins. In the following while loop example we see the while structure Line #1 - initializing the conditional variable (the conditional variable could be a number or string) Line #2 - the conditional check Line #3 - a block of statements Line #4 - Usually the last line in the statements is updating the conditional variable for recheck in line #2 my_var = 3 while my_var != 0: send_message("my_var = " + str(my_var)) my_var -= 1 © 2022 CodeMonkey Studios Ltd. 92 TO LESSON 8: While & Boolean Operators Part 2: 35 Minutes Playtime Cont. Log-in 1 min Review log-in instructions here. Playtime 20 mins. Have students complete exercises 35 through 38. Encourage them to go step by step. Pay attention to use the exact text as required in the exercise Use your classroom dashboard to keep track of student achievements. © 2022 CodeMonkey Studios Ltd. 93 TO LESSON 8: While & Boolean Operators Part 3: 5 Minutes Debriefing Debriefing 5 mins. Discuss the difference between == and != 5==5 → returns True 5!=4 → returns True Speak about the greater flexibility we have when using while loop No need to know the exact number of iterations before the loop starts Ability to run until a certain input is received © 2022 CodeMonkey Studios Ltd. 94 TO LESSON PLANS Lesson 9 – Advanced Operators The main part of the lesson is aimed at introducing the students to Boolean/logical operator. Please note that the minimum class time required for this lesson is 45 minutes. If you are rushed for time, please skip to Part 2. © 2022 CodeMonkey Studios Ltd. 95 TO LESSON 9: Advanced Operators Objectives Students will: Understand how to use more advanced conditional operators ‘not in’ and logical operators ‘and’ ‘or’ Update the game to include advanced conditional checks that are based on logical operators Complete exercises 39-43 © 2022 CodeMonkey Studios Ltd. 96 TO LESSON 9: Advanced Operators Components Terms: Boolean operators (AND, OR) View Glossary for more information © 2022 CodeMonkey Studios Ltd. 97 TO LESSON 9: Advanced Operators Part 1: 5 Minutes Introduction Activity – Conditional Group 5 mins. Divide the class into groups using AND and OR. Boolean operator - There are five Boolean operators that can be used in programming to expand the conditional checks At this point we will focus on AND and OR operators Ask students to split into 3 groups in accordance with the groups’ definition written on the board Define the groups in a way that one group will be empty, one is Or and one is AND Designing the board Group A: Group B: Group C: You can join this group if you are older than 9 You can join this group if you have long or curly You can join this group if you are older than 8 years old AND younger than 7 years old hair AND younger than 11 © 2022 CodeMonkey Studios Ltd. 98 TO LESSON 9: Advanced Operators Part 1: 5 Minutes Introduction Cont. Discussion 5 mins. Ask the following questions: Can you join more than one group? Yes Is there a group that no one could join? If so, why? Yes, group A because it is impossible to fit both conditions What’s unique about the empty group both conditions return FALSE What is the difference between group B and C - the difference between AND and OR In group B only one condition has to be met Group C both conditions has to B met © 2022 CodeMonkey Studios Ltd. 99 TO LESSON 9: Advanced Operators Part 2: 35 Minutes Playtime Explanation – ‘Not in’ 5 mins. This explanation corresponds with exercise 39 Remind students the use of ‘in’ operator "P" in "Python" → True "a" in "Python" → False How can we check if a string is ‘not in’ another string? The operator not in returns: True if the character is not in the string False otherwise The operators in and not in have opposite values: when the value of one is True, the other is False and vice versa. Definition : Not in (membership operator) – Has the value of True if a sequence with the specified value is not present in the object © 2022 CodeMonkey Studios Ltd. 100 TO LESSON 9: Advanced Operators Part 2: 35 Minutes Playtime Cont. Explanation – AND 5 mins. How can we check if two conditions are met? By combining two conditions using the AND operator The AND operator will return: True only if both of the values of the expressions (on either side of the operator) are True False in any other case Let’s define 2 variables and see how the AND operator works x=5 y = 10 What will be the output of the following check? send_message(x == 5 and y == 10) # True and True is True What will be the output of the following check? send_message(x == 5 and y == 5) # True and False is False © 2022 CodeMonkey Studios Ltd. 101 TO LESSON 9: Advanced Operators Part 2: 35 Minutes Playtime Cont. Explanation – AND cont. 5 mins. The table summarizes the AND operator. x == 5 y == 10 x == 5 and y == 10 True True True True False False False True False False False False © 2022 CodeMonkey Studios Ltd. 102 TO LESSON 9: Advanced Operators Part 2: 35 Minutes Playtime Cont. Explanation – OR 5 mins. This explanation corresponds with Exercise 42 How can we check that at least one of the conditions is met? Combining two conditions can be done by the OR operator The operator OR will return: True if at least one of the values of expressions (on either side of the operator) is True False otherwise Let’s define 2 variables and see how the OR operator works x=5 y = 10 What will be the output of the following check? send_message(x == 5 or y == 5) # True or False is True What will be the output of the following check? send_message(x == 10 or y == 5) # False or False is False © 2022 CodeMonkey Studios Ltd. 103 TO LESSON 9: Advanced Operators Part 2: 35 Minutes Playtime Cont. Explanation – OR cont. 5 mins. The table summarizes the OR operator, present it on the board together with the AND table so the students can see the difference. x == 5 y == 10 x == 5 or y == 10 True True True True False True False True True False False False © 2022 CodeMonkey Studios Ltd. 104 TO LESSON 9: Advanced Operators Part 2: 35 Minutes Playtime Cont. Log-in 1 min Review log-in instructions here. Playtime 20 mins. Ask students to complete exercises 39 through 43. When discussing exercise 43, explain the conditional check that will be added to the game The game will be changed to allow the player to continue guessing only if the word is not guessed yet and there are more tries left The condition of the while loop needs to combine two separate conditions into one condition. Use your classroom dashboard to keep track of student achievements. © 2022 CodeMonkey Studios Ltd. 105 TO LESSON 9: Advanced Operators Part 3: 5 Minutes

Use Quizgecko on...
Browser
Browser