“What are you doing, Barbie?” asks Skipper. “You haven’t moved from your laptop for hours!”
“I’m learning how to code, Skipper. This language is called Processing. It’s a good language for new learners, and it does amazing things with graphics. I can also program electronics like Arduino!”
“This puppy is so cute!” says Skipper. “You say you coded this?”
“I did!” beams Barbie. “I learned how to plot the shapes on the screen and use RGB color values. I also scaled the size and position of the eyes and nose so the puppy looks cute, and it’s all written in a reusable function!”
Barbie continues, “I’m working on a team project where each program will play against the others in a game like capture the flag. I get to help create an artificial intelligence algorithm – and see how everyone else in the class created theirs! It’s a cool project and I can’t wait to see how it turns out…. wait, what is THIS?”
“What’s going on, Barbie?” asks Skipper.
“Skipper, you have some mean comments on your Instagram photo from people I don’t even know. You never did change your privacy settings, did you?”
“Mean comments? Oh my gosh, those are horrible! Who would say such things to a random girl they don’t even know?”
“I hope this part of internet culture changes a lot over the next few years, Skipper,” says Barbie thoughtfully. “People like us need to make it clear to everyone else that you need to be just as polite online as you should be in person. For now, though, kid sister, you’ve got to take some steps to protect yourself. You’re 13. Lock down your privacy settings. Block those haters. Do not respond to them, and if you see it repeatedly, make sure you involve a trusted adult, OK?”
“But I want to be a famous YouTuber, so how will I get discovered if I lock down my privacy settings?”
“You are ridiculous, Skipper. Let’s talk later about maintaining your social media footprint. I’m heading to school. Don’t give up your day job!”
In her Computer Science class, Barbie brings up a debate her team had earlier that week. “Ms. Johnson, my team can’t decide between a more defensive strategy or a more offensive one for our capture the flag project. Do you have any suggestions?”
“Barbie, there’s a time when either strategy would be appropriate, and as you learn more about searching, game theory, and recursion, you’ll discover ways to look many moves out and determine which move of yours gives you the best chance of a winning outcome. Beginners usually have to run simulations on many different strategies and collect data. If you’re willing to put some effort into it, you, Steven, and Brian can play your strategies against each other and use data to determine the one for your final project.”
“I love a good challenge,” replies Barbie. “Steven and Brian, get your spreadsheets ready.”
“Barbie, Steven and I are going for coffee. Do you want anything?”
“Triple Americano, thanks Brian. I’ll keep plugging away at these simulations,” says Barbie gratefully.
“Barbie, can we talk?” asks Steven, crossing his arms. “You keep telling us what to do. We think you’re getting bossy.”
“Look.” Barbie pushes her glasses up. “You guys felt really strongly about your three-on-one strategy and put a ton of work into developing the algorithm. You could be right about it being better than my two-on-two. I’m open to all the possibilities, and I’ve listened to you every step of the way and never once called you bossy. Ms. Johnson suggested we do the thorough testing, and this is something we agreed on as a team. I really want to do this right.”
Barbie leans in and continues. “When it seems like I’m getting intense, you can chat with me about it without calling me a sexist label. Thanks for the Americano, and I’ll take a break after I have the coffee and we can analyze what we have so far and move forward.”
Weeks later, the team meets in the media center. “Barbie,” Steven says, “I have to admit, the hard work paid off and I feel really confident in a victory in the class tournament. If nothing else, I learned a ton from the process.”
“Yeah,” Brian chimes in. “Our algorithm is robust, abstract, and flexible. We have reusable functions and our code is even well-commented.”
“We taught ourselves object-oriented programming as well. I’m proud of our work for sure,” smiles Barbie. “We also had some tough times as a team, but overcoming those somehow makes the result better. I’m adding this project to my virtual portfolio so I can use it on college applications. Here, Steven, since you don’t have a Dropbox account, I made you a copy.”
“We did it!” shouts Brian at the conclusion of the class Capture the Flag tournament. “In our class, there were eight teams. Two didn’t finish, one got stuck in an infinite loop, one had a stack overflow, and we beat the other three!”
“This story wasn’t going to end any other way, because it’s a children’s storybook,” Barbie reminds Brian. “I recognize the other teams also learned a lot. But I’m proud of us for the problem-solving and hard work we did. If more people realized what it really feels like to be a computer engineer, there would be more of us out there. Oh, dude, did you get your acceptance letter to MIT?”
“Absolutely!” grins Brian. “I’ll see you on campus in the fall. There’s a coffee shop on campus that makes a phenomenal Triple Americano.”
Computer programs start to become more interesting, interactive, and powerful when you can create the ability for them to make decisions. The conditional is a key concept! The ability to take one of two paths, to make a yes/no decision, is crucial to computing and algorithmic problem solving.
This lesson weaves rates in with conditionals. Relevant standards:
CSTA:L2:CPP:5 Implement problem solutions using a programming language, including: looping behavior, conditional statements, logic, expressions, variables, and functions.
Compute unit rates associated with ratios of fractions, including ratios of lengths, areas and other quantities measured in like or different units. For example, if a person walks 1/2 mile in each 1/4 hour, compute the unit rate as the complex fraction 1/2/1/4 miles per hour, equivalently 2 miles per hour.
Represent proportional relationships by equations. For example, if total cost t is proportional to the number n of items purchased at a constant price p, the relationship between the total cost and the number of items can be expressed as t = pn.
The students’ task, as explained in the video, is to write a program that can help solve a common dilemma for me as a teacher. If two classes are racing to complete a game, and the two classes take different amounts of time but also have different amounts of students, how do I determine who won? Variables and expressions could be used to calculate the rates, and then a conditional statement would determine which class won.
The students did pairs programming for this activity. Each group opened the starter program which has the task in the comments.
After the groups worked on the task, we discussed some of the solutions. There were two main approaches:
Approach 1: Calculate the time per student. Lowest amount of time per student wins.
Approach 2: Calculate the number of students per second. The greater number of students per second wins.
Some common misconceptions were: adding the seconds and minutes together and treating that as the total time (instead of converting the minutes to seconds and then adding), misunderstanding the rate of time per student vs. students per second, and failing to use parentheses in their rate calculation, so the order of operations would make division happen before addition. (example: rate = min * 60 + sec / students; rather than rate = (min * 60 + sec) / students;)
The students did a great job overall, and the level of challenge seemed appropriate for most. I truly think the mathematics and the programming were at a very appropriate level of challenge, but as we get deeper into programming, students need to be more metacognitive, they need to ask questions of each other, they need to be resourceful in finding answers – and many students lack those skills.
We will learn about boolean expressions next with these ideas in mind!
To introduce students to variables and expressions, I used a flipped lesson on using formulas to calculate area, and then a pairs programming activity on divisibility.
Relevant CSTA and CCSS standards. I decided to have the kids work with the area of an ellipse because they enjoyed that connection with the area of a circle – it’s a challenging formula to write in a program, as well.
CSTA:L2:CPP:5 Implement problem solutions using a programming language, including: looping behavior, conditional statements, logic, expressions, variables, and functions.
Know the formulas for the area and circumference of a circle and use them to solve problems; give an informal derivation of the relationship between the circumference and area of a circle.
Apply properties of operations as strategies to multiply and divide rational numbers.
To give the students vocabulary and build knowledge of syntax, I made a little video lesson for them to create shapes and calculate their area. This is their first introduction to assignment statements.
Their individual assignment was to finish the program, drawing an ellipse and calculating its area using a formula they found in a search engine. Many students didn’t process that the height and the width of the ellipse weren’t the same as the two radii, so they calculated pi * height * width to calculate area. I mentioned that I had remembered a circle had just about the same area as 3/4 of the area of the square enclosing it, so could it make sense that the ellipse had a greater area than a rectangle with the same width and height? The students partnered up to troubleshoot and write the expression correctly – some form of ea = 3.14159 * eh / 2 * ew / 2; We had a good discussion about whether or not parentheses were necessary in the formula.
a = floor (b / c); // divides b / c. truncates to a whole number with floor().
a = floor (6/3); // a is assigned to 2
a = floor (10/3); // a is assigned to 3
a = floor (104 / 10); // a is assigned to 10
a = b % c; // divides b / c and assigns a to the remainder.
a = 6 % 3; // a is assigned to 0
a = 10 % 3; // a is assigned to 1
a = 104 % 10; // a is assigned to 4
The next activity was a pairs-programming activity. I asked the students to find a partner. One would type, the other would look over their shoulder, read the prompt, make suggestions, and help troubleshoot. I set a timer so the roles would switch after 10 minutes. Students have a hard time switching roles! The one using the keyboard gets very comfortable in that position and the one not typing often is self-conscious about it. It will take some coaching for the kids to get more comfortable with pairs programming, but it will be worth it.
I gave the students a scenario. Let’s say I walk into a bank with 2778 pennies. I want to come out with the smallest number of coins and bills possible, so what will the bank give me and how did you come up with it?
We had a whole-class discussion about using division and modulo to come up with a twenty, a five, two ones, three quarters, and three leftover pennies. The students then got a starter program and started pairs programming. The starter program was about a fictional money system and making change.
This was a really challenging task and it would need quite a few catch-and-release times. I should have used more! During the summary, two different approaches to solving the money problem came out.
Solution 1: Convert to the biggest currency unit first, then divide up the leftovers. Some students related the problem to how we convert money. If I have 2778 pennies, I’ll look for how many hundreds, fifties, or twenties I can make first and work down. These kids had to calculate that there are 105 zinks in a zab and then work from there.
Solution 2: Convert to the second-smallest currency unit first, then make groups of the next-smallest, and so on. Each time the leftovers get assigned to the small currency units.
Great intro to variables and expressions – next we would tackle conditionals.
CSTA:L2:CPP:5 Implement problem solutions using a programming language, including: looping behavior, conditional statements, logic,
expressions, variables, and functions.
So interesting that the stuff we spend most of our time on in CS class is summarized in this one standard. Each item could be (well, usually is) expanded into a whole week’s worth of content or more!
I chose to start our JS unit with variables, expressions, and conditionals – the assessment was focused on these topics.
I decided to give the students a written quiz and also a performance task. I put both in a Google Doc, and I created an assignment in Google Classroom for the students to submit their performance task to me.
The written quiz has 3 questions, which are in the Google Doc. I had the students answer these on paper.
Question 1 asks students to determine the value of variables after several assignment statements.
Question 2 asks them to choose the best assignment statement for a given situation.
Question 3 asks the students to evaluate Boolean expressions.
I had a devil of a time writing the assessment, and at a first glance, I don’t think the students did very well. There are so many interwoven strands that it’s very, very hard to isolate individual skills you need to be a programmer. Kids need to know the syntax of the language, order of operations, mathematical modeling, the meaning of percents and decimals, and rules for operations on integers. They have to be detail-oriented enough to notice nested parentheses and they have to be good writers to explain their reasoning. If a student misses a question – how do I know which skill is deficient? Some students don’t understand that multiplying by a decimal makes a number smaller, or that multiplying by 0.25 doesn’t give you a 25% discount. Can I still assess whether they understand variables and expressions, or are those skills too entangled to separate them?
Tough call, and I’ll continue to search for ways to get that information.
I was prouder of the performance task. Here was the prompt. Students needed to create a new program on Khan Academy and work individually.
In a sports tournament, the tigers will play the lions, and the eagles play the hawks. The winners of these two games will play in the championship.
These 4 variables represent the scores in the first game.
Write a program that will write the names of the two teams playing in the championship. If there’s a tie in either game, you should write a message explaining that the game goes into overtime.
When you submit your assignment, you can attach a link to your Khan Academy program, or copy your program into a Google Doc and attach that here.
Everyone must do their own work.
When I gave kids the task, the room got very, very quiet and there was 100% focus on creating their computer programs. I kept a clipboard with me. If students asked a question or if I gave them a hint, I made a tally on the clipboard. Some very quick students finished their programs early. Some took the entire class period to write a pretty simple program. Some kids took the entire class period to make programs that were really elaborate, with functions and multi-game simulations. The cool thing was, every kid’s program was different.
Here are some of my anchor quizzes.
A “2”. Student shows some misconceptions but is progressing. In this case, the student isn’t clear on the inequality symbols.
A “1”. This student is missing some major concepts.
I knew I would have some students who had been letting their friends carry the load of learning to program, who would be mighty lost during the assessment. I was right, but ultimately I want the kids to learn to code and my interest wasn’t in letting them fail. I made marks on my clipboard and pointed them to the documentation on Khan Academy – the sample code that used “if” statements and created text. I re-read the prompt with them and questioned them, and then cut the kids loose when the light bulb went on. I won’t give those students the grade for mastery, but some may have shown proficiency.
One of these students was really grateful for the opportunity to do the individual work. “I finally understand if statements!” That was the goal!
I’m bothered by the handful of students that turned in programs that were obviously not close to working. In programming, it’s very clear whether or not your product meets a standard. Why turn it in otherwise? I want the kids to demand more from themselves. On one hand, they were academically honest and didn’t turn in someone else’s work, but on the other, there were resources available to help them and they chose not to use the resources. I gave one student a pass to come in during ELO time and get help. He didn’t show up. What makes you just throw your hands up and quit?
Those students are high on my worry list, not just for computer programming – but for life. Here I go, fretting over teaching Grit.
To end on a positive note, most kids persevered, they created interesting and creative programs, and I loved grading the assignments using Google Classroom. I had the kids paste a link to their program in their assignment submission, and I’m in the process of working my way down the list and assigning grades. Easy!