Day 11 (WC)

LESSON 1

Goal: Before you leave class today you will be introduced to CodeHS and how Karel the Dog can be given a set of instructions to perform a simple task.

  1. Sign up for www.codehs.com. HERE IS HOW:
    1. Go to: codehs.com
    2. Class code: AD980
    3. If prompted, use your school Google account to sign in
    4. Acclimate yourself! Look around!
  2. Complete the CodeHS Pretest/Survey–get it from your teacher
  3. Complete the JavaScript Knowledge & Skills Pretest–get it from your teacher
  4. Log into CodeHS and do Lesson 1
    1. Get the Meet Karel the Dog handout from your teacher
    2. Watch 1.1.1 Introduction to Programming With Karel
    3. Do:  1.1.3 Our First Karel Program–change it up a little to experiment!
    4. Do:  1.1.4 Your First Karel Program–show me when you are done
    5. Do: 1.1.5 Short Stack–show me when you are done
    6. If time permits: discover what else Karel can do by checking out the Cheat Sheet.
  5. FYI: CodeHS Online Textbook–use this as a resource
  6. BEFORE YOU LEAVE, WRITE ABOUT THE FOLLOWING in the Word Online file named Web Apps & Coding for this class (you will write in this file daily): What can Karel teach us about computing?

LESSON 2

GOAL: You will learn about Karel’s ‘World’ and the ways that Karel can interact with it.

VOCAB:

Term Definition
lowerCamelCase lowerCamelCase is a naming convention where the first letter is lower case, and each subsequent start of a word is upper case.
World A “world” or “Karel World” is a grid that karel lives in.
Karel Karel is a dog who listens to your commands.
Command A command is an instruction you can give to Karel.

DO THIS IN ORDER:

  1. REVIEW:
    1. Get the Karel Commands handout from your teacher and complete it–raise your hand when you are done
    2. Do this online quiz:  1.1.2 Quiz: Karel Commands
  2. Watch:  1.2.1 More Basic Karel
  3. Do:  1.2.3 Tennis Ball Square–experiment with it!
  4. Do:  1.2.4 Make a Tower–show me when you are done
  5. Do:  1.2.5 Pyramid of Karel–show me when you are done
  6. If time permits: discover what else Karel can do by checking out the Cheat Sheet.
  7. FYI: CodeHS Online Textbook–use this as a resource
  8. BEFORE YOU LEAVE, WRITE ABOUT THE FOLLOWING in the Word Online file named Web Apps & Coding for this class (you will write in this file daily):
    1. How can we make Karel turn right, even though Karel doesn’t know a turn right command?
    2. What is a street in Karel’s world?
    3. What is an avenue in Karel’s world?
    4. What are the directions Karel can face?

LESSON 3

GOAL: Karel can learn new words or commands through the use of functions. This is called defining a functions. Defining functions has syntax rules.

VOCAB:

Term Definition
Define a Function Defining a function means to teach the computer a new command and explain what it should do when receiving that command.
Call a Function Calling a function actually gives the command, so the computer will run the code for that function.

DO THE FOLLOWING IN ORDER:

  1. REVIEW:Do:  1.2.2 More Basic Karel Quiz
  2. WATCH:  1.3.1 Karel Can’t Turn Right
  3. Do:  1.3.3 Tower and Turn Right–experiment!
  4. Do:  1.3.4 Slide Karel–show me
  5. Do:  1.3.5 Fireman Karel
  6. Did you get it?!  1.3.6 Karel Turns Right Badge
  7. If time permits: Rewrite previous exercises using functions.
  8. FYI: CodeHS Online Textbook–use this as a resource
  9. BEFORE YOU LEAVE, WRITE ABOUT THE FOLLOWING in the Word Online file named Web Apps & Coding for this class (you will write in this file daily):
    1. What are functions?
    2. Why are functions useful?
    3. Write out a function for an everyday activity that you perform, for example:
      function eatSandwich(){bring sandwich to mouth;bite down;chew;}

LESSON 4

GOAL: Functions are used to teach Karel a word or command. Using functions allow us to break down our program into smaller pieces and make it easier to understand.

VOCAB:

Term Definition
Define a Function Defining a function means to teach the computer a new command and explain what it should do when receiving that command.
Call a Function Calling a function actually gives the command, so the computer will run the code for that function.
Curly Bracket An open curly bracket is { and a close curly bracket is }
Function body The part of a function that contains the commands

DO THE FOLLOWING IN THIS ORDER:

  1. REVIEW:
    1. Get the Karel Can’t Turn Right handout from your teacher & complete it–show me before moving on
    2. Get the What’s Wrong with This Function? handout from your teacher & complete it–show me before moving on
    3. Do:  1.3.2 Karel Can’t Turn Right Quiz
  2. Do the Dancing with Functions class activity–get the handout from your teacher
  3. Watch:  1.4.1 Functions in Karel
  4. Do & experiment:  1.4.3 Turn Around
  5. Do & show me:  1.4.4 Pancakes
  6. Do & show me:  1.4.5 Mario Karel
  7. If time permits: Create an original Sandbox program that defines and calls a minimum of 4 (four) functions.
  8. FYI: CodeHS Online Textbook–use this as a resource
  9. BEFORE YOU LEAVE, WRITE ABOUT THE FOLLOWING in the Word Online file named Web Apps & Coding for this class (you will write in this file daily):
    1. Why are functions important?
    2. How do functions change how we think about our programs?

LESSON 4–FINISH

  1. Dancing with Functions
  2. Finish & Show me 1.4.4 & 1.4.5

LESSON 5

GOAL: You will gain a deeper understanding of functions. You will be able to explain the importance of writing readable code, and you will be able to analyze and compare the readability of different programs. You will be able to use the start function to make your programs more readable.

VOCAB:

Term Definition
Read Like a Story Programs that “Read like a story” have good decomposition and make the code easy to follow.
Define a Function Defining a function means to teach the computer a new command and explain what it should do when receiving that command.
Call a Function Calling a function actually gives the command, so the computer will run the code for that function.
Start Function This is the function that is called when you click run.

DO THE FOLLOWING IN ORDER:

  1. REVIEW:
    1. Get the Naming Functions handout from your teacher & complete it–show me before continuing
    2. Get the What’s Wrong with the Functions? handout from your teacher & complete it–show me before continuing
    3. Do:  1.4.2 Functions in Karel Quiz
  2. Watch:  1.5.1 The Start Function
  3. What did you notice about the format and syntax of calling functions?
  4. Do & experiment:  1.5.3 Tower with Start Function
  5. Do & show me:  1.5.4 Pancakes with Start
  6. You are going to create your own Karel program using the Sandbox feature. Its important that before you edit Karel worlds that you have an objective for what you would like Karel to do. Write out what the objective is first, then develop a solution for it in your Word Online file for this class.
  7. Create a new Karel program using the Sandbox feature:
    1. Click on the Sandbox tab.
    2. Let’s create a new Karel program together by naming it MyFirstKarelProgram and choosing KAREL for the type of program.
    3. Click on Edit Karel Worlds and try to:
      • Move Karel’s start row and column
      • Changing the width and height
      • Changing Karel’s start direction
      • Adding and Removing a Ball
      • Adding and Removing a Wall
      • Moving Karel
  8. Extra Credit Opportunities:
    1. Create a poster that lists the rules or Do/Don’ts for defining and calling functions.
    2. My Day in Functions–Think about your typical school day. What are the functions that you routinely perform that can be defined like a function? Write out what your day looks like by writing at least 3 functions and calling them throughout your day.Examplefunction start(){snapChat();takeNotes();}function snapChat(){openApp();takePhoto();

      send();

      }

      function takeNotes(){

      takeOutPaper();

      writeVocabWords();

      }

LESSON 6

GOAL: Students will be able to…

  1. Break a large problem down into smaller pieces
  2. Write methods to solve each smaller problem
  3. Solve a complicated problem using Top Down Design
  4. Identify good and poor decomposition

VOCAB:

  1. Break Down (Decompose)–Breaking down (decomposing) your code is splitting it into more functions.
  2. Read Like a Story–Programs that “Read like a story” have good decomposition and make the code easy to follow.
  3. Indentation–Indentation is the visual structure of how your code is laid out. It uses tabs to organize code into a hierarchy.
  4. Decomposition–Decomposition is breaking your program into smaller parts.
  5. Top Down Design–Top down design is a method for breaking our program down into smaller parts.

DO THE FOLLOWING IN THIS ORDER:

  1. REVIEW: 1.5.2 The Start Function Quiz
  2. Do the Decomposition Activity–Get the handout from your teacher
    1. Write the instructions for making a peanut butter and jelly sandwich
    2. Using a student volunteer, execute student instructions to make a sandwich as a computer would. Did it work the way you thought it would?
    3. You are not allowed to interpret what the instructions mean, only to execute the instructions literally.
  3. Watch: 1.6.1 Top Down Design and Decomposition in Karel
  4. Using the graphic organizer shown in the video, break down or decompose the process of making a PB & J. Notice how the process can be broken down into functions such as putIngredientOnKnife() or spreadTheIngredients().
  5. 1.6.3 Hurdle Karel
    1. Look at the example of exercise Hurdle Karel. Without running the program, predict what Karel will do and write the pseudocode:  1.6.3 Hurdle Karel
    2. Write your pseudocode on the board so that the class may follow it as the example is run.
    3. Run Hurdle Karel and compare your pseudocode to the actual result of the program. 1.6.3 Hurdle Karel
    4. What did you notice?
  6. 1.6.4 The Two Towers
    1. Notice the starting world and the result world of Karel.
    2. Identify the objective, the preconditions, postconditions.
    3. It might be helpful to move Karel to avenue (2, 1) so that you can see where Karel will begin when she begins to build the Tower.
    4. Once Karel is moved to (2, 1), write the first commands for the buildTower() function.
    5. Be sure to use good style in writing functions by indenting code and using proper syntax.
    6. Before getting with a partner to build the start function, you will need two helper functions.
    7. Once the buildTower() function is built as a class, break into pairs and begin to build the start function.
  7. If time permits:
    1. Decompose more complicated tasks from your every day life
    2. Decompose the same problem into multiple solutions with various levels of granularity
      1. For example, Making a PB&J could have the following answers
        1. Take bread and PB out of cabinet, take Jelly out of fridge, combine ingredients into sandwich
        2. Raise arm, Grasp cabinet handle, Pull handle to open door, etc… (this is probably more granular than you would like, but hopefully you understand the idea!)
  8. FYI: CodeHS Online Textbook–use this as a resource
  9. BEFORE YOU LEAVE, WRITE ABOUT THE FOLLOWING (respond to just 2 out of the following 7 questions) in the Word Online file named Web Apps & Coding for this class (you will write in this file daily):
    1. What did you learn in this lesson/day?
    2. How did you learn it?
    3. What was your “a-ha!” moment? What sparked it?
    4. When did you get stuck? How did you get “unstuck”?
    5. Why is it useful to be able to break down problems into smaller sub problems?
    6. Is this strategy only useful for programming? What other situations might we apply this method of problem solving to?
    7. Describe how you helped Karel break down a big problem into a smaller problem today. How did that affect how you wrote your code?

LESSON 7

GOAL: Students will be able to…

  1. Explain the preconditions and postconditions of a function
  2. Create clear and readable comments in their code that help the reader understand the code
  3. Explain the purpose of comments
VOCAB: 
  1. Programming Style–The way your code is written is the style. It covers the aspects of the code that goes beyond whether or not it just works.
  2. Comment–A message in your code that explains what is going on.
  3. Precondition–Assumptions we make about what must be true before the function is called.
  4. PostconditionWhat should be true after the function is called

DO THE FOLLOWING IN ORDER:

  1. REVIEW:
    1. Do:  1.6.2 Top Down Design and Decomposition Quiz
    2. Do the Planning Programs 1 activity–get it from your teacher–work with a partner
  2. Click on example  1.7.3 Hurdle Karel. Read the code in green. What purpose do you think the code serves in the program? Does the code in green affect the program?
    1. Can you identify the direction and avenue that Karel faces in the starting world? This is known is as a precondition.
    2. Can you identify the direction and avenue that Karel faces in the result world? Also note the amount of balls in the tower and how many were built. This is known is as a postcondition.
    3. Complete The Two Towers + Comments exercise in pairs or individually.
    4. Because of your hard work with defining and calling functions, you have unlocked the super powers of Karel. These super powers are the ability to turn right and turn around without having to define it as a separate function.
    5. Examine the example in Hurdle Karel (with SuperKarel).
      *Students complete The Two Towers + Super Karel using the turnRight() command.
  3. If time permits: Go back through previous Karel exercises and add pre and postconditions to your code
  4. FYI: CodeHS Online Textbook–use this as a resource
  5. BEFORE YOU LEAVE, WRITE ABOUT THE FOLLOWING in the Word Online file named Web Apps & Coding for this class (you will write in this file daily):
    1. What are the two types of comments?
    2. What is the benefit of using comments?
    3. Are there times you wouldn’t write a comment? Why?

LESSON 8

GOAL: Students will be able to…

  1. Write programs that use SuperKarel instead of Karel
  2. Utilize the new toolbox of commands that SuperKarel provides over Karel
  3. Read documentation to understand how to use a library (SuperKarel is an example of this)

VOCAB:

SuperKarel SuperKarel is like Karel but already knows how to turnRight() and turnAround()

DO THE FOLLOWING IN ORDER:

  1. REVIEW:
    1. Do  1.7.2 Commenting Your Code Quiz
    2. Do the Commenting Code activity–get the handout from your teacher
  2. Click on example  1.8.3 Hurdle Karel (with SuperKarel). Read the code in green. What purpose do you think the code serves in the program? Does the code in green affect the program?
  3. Watch 1.8.1 Super Karel video
  4. Do 1.8.4 The Two Towers + SuperKarel & show me
  5.  1.8.5 Super Karel Badge Did you get it?!
  6. If time permits: Go back through previous Karel exercises and add pre and postconditions to your code
  7. FYI: CodeHS Online Textbook–use this as a resource
  8. BEFORE YOU LEAVE, WRITE ABOUT THE FOLLOWING in the Word Online file named Web Apps & Coding for this class (you will write in this file daily):
    1. How is SuperKarel different from Karel?
    2. Where can you go to read about all of SuperKarel’s built in commands?

LESSON 9

GOAL: Students will be able to…

  1. Create for loops to repeat code a fixed number of times
  2. Explain when a for loop would be a useful tool
  3. Utilize for loops to write programs that would be difficult / impossible without loops

VOCAB:

  1. Loop–A loop is a way to repeat code in your program.
  2. For Loop–A for loop lets us repeat code a fixed number of times.
  3. Control Structure–A control structure lets us change the flow of the code.
  4. Curly Bracket–An open curly bracket is { and a close curly bracket is }
  5. Parentheses–( and )

DO THE FOLLOWING IN ORDER:

  1. REVIEW: 1.8.2 Super Karel Quiz
  2. Think about this: create a function that will enable Karel to climb one stair. What if Karel needed to climb 100 stairs? What part of your code would you need to repeat? What part of you code will be repeated? How many times will the code be repeated?
  3. Watch  1.9.1 For Loops
  4. Look over  1.9.3 Repeated Move
    1. Notice how the condition inside the parentheses works by stating that:
      1. The variable i is initialized, or started at the value of 0.
      2. The i < 9 determines the point that the loop will stop.
      3. i++ increments, or increases the value of i.
      4. All parts in the condition within the parentheses are separated by a semi-colon, expect the last statement
  5. Run 1.9.3 Repeated Move and  1.9.4 Put Down Tennis Balls example and note how the value of i at the bottom of the screen increases and keeps track of how many times Karel has looped through the statement.
    1. Experiment with the code by changing the value of i.
  6. Do  1.9.5 Take ’em All
  7. Do  1.9.6 Dizzy Karel
  8. Do  1.9.7 For Loop Square
  9. Do  1.9.8 Lots of Hurdles
  10. If time permits: In the example exercises Repeated Move & Put Down Tennis Balls, write functions using for loops
  11. FYI: CodeHS Online Textbook–use this as a resource
  12. BEFORE YOU LEAVE, WRITE ABOUT THE FOLLOWING in the Word Online file named Web Apps & Coding for this class (you will write in this file daily):
    1. For loops are a part of all programming languages, why do you think that is?
    2. Why are for loops useful?
    3. For loops extend the limits of what we can do with our programs. What is one Karel program you could write with a for loop that you couldn’t do without one?
    4. Think of and write down three real-life scenarios that could use a for loop.
    5. What did you learn in this lesson/day? How did you learn it? What was your “a-ha!” moment? What sparked it?When did you get stuck? How did you get “unstuck”?

LESSON 10

GOAL: Students will be able to…

  1. Use conditions to gather information about Karel’s world (is the front clear, is Karel facing north, etc)
  2. Create if statements to only execute code if a certain condition is true

VOCAB: 

  1. ConditionA condition is code that you put inside an if statement or while-loop.
  2. If Statement–An if statement lets you ask a question to the program and only run code if the answer is true.
  3. Control Structure–A control structure lets us change the flow of the code.
  4. Parentheses–( and )

DO THE FOLLOWING IN ORDER:

  1. REVIEW:
    1. Do  1.9.2 For Loops Quiz
    2. Complete the For Loops handout individually or in pairs.
  2. What determines what time you will go to bed? What determines when you will ask for help in class? What determines when you eat birthday cake? Point out the condition in each of the If statements on the board. Identify what code is executed if the condition is true.
  3. Watch  1.10.1 If Statements
  4. Look at  1.10.3 If Statements by comparing and contrasting what occurs to Karel when the start function is initialized.
    1. Why do you think Karel crashed when the start function is initialized?
  5. Examine 1.10.4 Safe Take Ball example in pairs or individually.
  6. Do & show me  1.10.5 Is There a Ball? individually or in pairs.
  7. FYI: CodeHS Online Textbook–use this as a resource
  8. BEFORE YOU LEAVE, WRITE ABOUT THE FOLLOWING in the Word Online file named Web Apps & Coding for this class (you will write in this file daily):
    1. Write if statements for real life scenarios. Examples include:
if (zombiesPresent()){
    runAndHide();
}

if (favoriteSongOnPandora()){
    dance();
}

LESSON 11

GOAL: Students will be able to…

  1. Explain the purpose of an If/Else statement
  2. Create If/Else statements to solve new types of problems
  3. Identify when an If/Else statement is appropriate to be used

VOCAB: 

  1. If Statement–An if statement lets you ask a question to the program and only run code if the answer is true.
  2. If Else Statement–Control structure that lets us do either one section of code or another depending on a test.
  3. Control Structure–A control structure lets us change the flow of the code.

DO THE FOLLOWING IN ORDER:

  1. REVIEW:
    1. Do 1.10.2 If Statements Quiz
    2. Complete the To If, Or Not To If handout individually or in pairs.
  2. Do Now: Your best friend and you agree to go to the theater to see the latest action hero movie. When you arrive however, you are saddened to find out that it has sold out. What activity might you do instead? If that activity can’t be done, what else might you and your friend do to have a fun evening?
    1. Record them as an if/else statement with correct syntax.
    2. What did you notice about what you wrote and how the code is executed?
    3. What might your default command be (goHome(), goToBed(), etc)?
  3. Watch 1.11.1 If/Else Statements
  4. Explore  1.11.3 If/Else Statements and 1.11.4 One Ball in Each Spot exercises.
  5. Do & show me 1.11.5 Right Side Up & 1.11.6 Right vs. Left Square individually or in pairs.
  6. FYI: CodeHS Online Textbook–use this as a resource
  7. BEFORE YOU LEAVE, WRITE ABOUT THE FOLLOWING in the Word Online file named Web Apps & Coding for this class (you will write in this file daily):
  1. Explain the difference between an if statement and an if/else statement.
  2. Give an example of a problem that Karel would need an if statement to solve
  3. Give an example of a problem that Karel would need an if/else statement to solve
  4. Why are if/else statements useful?
  5. Write out real life scenarios that would involve if/else statements. For example:
if(favoriteSongOnPandora()){
    dance();
} else {
    doHomework();
}

Leave a Reply

Your email address will not be published. Required fields are marked *