The main purpose of this lesson is start our programming journey that focuses on problem-solving over learning syntax. Stripping down the available commands to only a few forces us to think about the most efficient way to solve the problem and come up with creative ways of doing it.A reason to learn this way is because at its core, a computer can really only do a few simple things: load a number from memory, store a number in memory, add two numbers together, etc. Everything the computer can do is the result of combining these simple instructions to do more and more sophisticated things. We will add more complexity as we go. When programming at any level of expertise you are always limited by the constraints of the programming language you choose to use. Whether the language gives you thousands of commands and libraries with which to control various things or only a few, you always have to use those as building blocks to get the computer to do what you want. It usually involves being creative and making interesting choices about how to go about doing something.
The challenge - and fun - of programming at its core, is understanding how to use and combine those machine instructions to make the computer do what you want, or to solve a problem.
We saw this in Unit 1 with the Internet, as we built up complex routing and naming protocols, all from solving the initial problem of how to coordinate communication between two people on a shared wire. We saw this in Unit 2 with complex data types, all built up from simple binary codes. We will do the same thing with programming! To learn about programming we are going to solve problems with only a few primitive commands. You will learn how you can build up very complex computer programs from only a few simple elements.
App Lab is the programming environment we will use in the Computer Science Principles course. App Lab uses both a block based and JavaScript language.You can access it from the Code.org link. We will check out the video together to see how to use App Lab.
You will complete activities 2 - 4.
What does efficiency mean? Why is it important?
Why constrain to 4 commands?
Programming languages define the meaning of a set of general & useful commands. Nearly all programming languages provide a way to define and call new commands which programmers use for problems they are trying to solve.
Defining functions is an example of how computer scientists use abstraction to solve problems. A programmer will design a solution to a small, specific problem or task and then give it a name. When that problem comes up again, the programmer can use the new function by name, without having to solve the problem again.
In the previous lesson we created simple turtle drawings using only four commands. At some point you probably wished that more commands were available to you. What commands would have been helpful? Why?
We will watch the video about defining and calling functions together.
The example programs have been written in the preferred style for this curriculum. These choices do not affect the functionality of a program but may affect how clearly a program can be read. As a consistent style is used programs will be easier to read and write.
You will complete challenges 2 - 8 from Stage 5.
We will look at the vocabulary words from this chapter on the code studio.
“Do you think programmers memorize all of the commands in a programming language? If not, how is anyone ever able to use an entire programming language?“
Complete CSP Unit 3 Lesson/Stage Puzzles 2 - 10 on Code Studio.
The basic idea is that you often want to write a function that takes some input and performs some action based on that input. For example, the turtle function moveForward is much more useful when you can specify how much to move forward (e.g., moveForward(100)), rather than just a fixed amount every time.
It’s very common to encounter situations where as a programmer you realize that you basically need a duplicate of some code you’ve already got, but you just want to change some numbers. That’s a good time to write a function with a parameter; the parameter just acts as a placeholder for some value that you plug in at the time you call the function.
Just like it’s considered good practice to give descriptive names to your functions, the same is true for the names of the parameters themselves. For example: drawSquare(sideLength) is better than drawSquare(stuff).
Complete CSP Unit 3 Lesson/Stage 8 Puzzles 2 - 12 on Code Studio.
As we have developed as programmers, we have focused on the process of breaking down large tasks into smaller pieces and assigning each piece a function.When we break down a large task, often we will find that some portion of the task needs to be repeated many times. As programmers, we would simply call the same function many times. This might work if we need to call the same function five times, but if that function needs to be run 1,000,000 times, we’ll need a better solution.Today we’ll be exploring how a loop solves this problem by allowing us to repeat a set of commands many times.We’ll also practice looping through commands many times with random input, therefore giving us many instances of random output.
This will be both useful for testing our code and also for developing more variety in our drawings.
Complete CSP Unit 3 Lesson/Stage 9 Puzzles 2 - 13 on Code Studio.
This will be the final project for this Code.org intro to programming unit. Use the links below to complete this project. Since we have a small class, this project will be completed individually. This project is intended to prepare students for the AP test.
Planning Guide - Design a Digital Scene - Send me the Product Description on Pg. 3
Practice PT Overview and Rubric - Design a Digital Scene