8th Grade Computer Science

Code it out.

  • Course Length: 18 weeks
  • Course Type: Elective
  • Category:
    • Technology and Computer Science
    • Middle School

Schools and Districts: We offer customized programs that won't break the bank. Get a quote.

Get a Quote

This is it. The final middle school computer science course. The last hoo-rah…until high school computer science and a lifetime of professional coding, 1337 speak, and coffee-guzzling.

While you're here closing out middle school-level CS, though, we're going to make it big. No more block-based languages for you. Nope. This time around, you're going to be working with Python, a 100%, Grade A, text-based programming language. There will still be images and turtles, but you'll be commanding them using nothing but words. In this semester-long, CSTA-aligned course, you'll learn all the tools you need to program, like:

  • Data types
  • Variables
  • Loops
  • Conditions
  • Functions
  • Objects and classes

Plus, once you learn Python, you'll be ready to learn any other programming language you want. All the drag-and-drop programming languages will be so jealous.


Unit Breakdown

1 8th Grade Computer Science - Python 101

This unit's all about getting Python up and running…plus or minus a few games about candy. Digital candy.

2 8th Grade Computer Science - By the Numbers

You can write all the letters you want to screen, but at the end of the day, it all comes back to numbers. To keep track of all those numbers, you'll need some variables. Luckily, we're here to talk about them in this unit.

3 8th Grade Computer Science - String Theory

Numbers can't have all the variables to themselves. Sometimes we need strings to say things on the computer. Plus, strings have tons of interesting built-in functions called methods that make working with words fun—no matter how you feel about English class.

4 8th Grade Computer Science - To Do List

Computers love staying organized with lists. You'll probably end this unit loving lists, too, since they let you keep things organized without any work. Or…without much work, anyway.

5 8th Grade Computer Science - Loops and More Loops

Having to repeat your work isn't fun. Luckily, computers are great at repeating things without complaining about the lack of lunch breaks. That means less time coding and more time nomming on cafeteria fries.

6 8th Grade Computer Science - On One Condition

Everything has conditions. Checking out library books. Downloading free software. Dipping food in a chocolate fountain. Computers have conditions, too, and learning them is going to make your code even more interesting. And, uh…remember to read the terms and conditions on that software, yeah? You never know when they're going to add a clause about selling your soul.

7 8th Grade Computer Science - How to Function

Up till now, loops have dominated the repeating-code game. Now it's time to make some functions so that you can run the same code in different sections of the program. It's a brave new programming world.

8 8th Grade Computer Science - Digital Citizenship

The best part about computer science is that anyone can do it. The worst part about computer science is that anyone can do it. When you're working with other people's code and information, you'll need to make sure that data's reliable. Otherwise, your work could be unreliable at best—and end up filled with lies at worst. We'll give you some tips and tricks to keep the facts straight in this unit.

9 8th Grade Computer Science - Have Some Class

Objects are great, but you know what's better than using standard classes to make them? Building your own custom classes. It'll be like hacking Ikea, except without breaking any warranties.

10 8th Grade Computer Science - Drawing with Turtles

Drawing on the computer is more fun with some reptiles to handle the movements. Trust us on this one; the turtle's going to become your best friend.

11 8th Grade Computer Science - Good GUI

With the help of Tkinter and turtles, you're going to make your own graphical user interfaces this unit, also sometimes called GUIs. Without GUIs, you wouldn't have any buttons or images on your screen. How dull.

12 8th Grade Computer Science - Python Charming

In the final unit, you'll be using all your Python knowledge to make your own turtle-drawing app. Feel free to ooh and ahhh when you're done.


Recommended prerequisites:

  • 7th Grade Math—Semester A
  • 7th Grade Math—Semester B

  • Sample Lesson - Introduction

    Lesson 2.02: Calling All Variables

    A pile of Poké Balls.
    "electric_pokemon_pikachu, I choose you!"
    (Source)

    At this point, creating and setting values for variables is NBD. Give it a name, attach an equals sign, and then slap a value at the end. But what's going on behind that declaration? There's got to be more going on and…there is.

    To help better understand how these suckers work, think about Pokémon. Once you've got those values inside the variables, you can pull out a variable name any time you want and they'll fight for you…depending on your definition of "fight."

    If "fight" means that they'll give you the value, then yeah. It's totally fighting.

    On top of all that fighting, your variable/will let you change their value whenever you want, which is like evolving Pokémon except way easier than evolving real Pokémon.

    That is, evolving real fake Pokémon.


    Sample Lesson - Reading

    Reading 2.2.02: Call and Reset

    Now that you know how to create variables, the next step is something you're familiar with if you've ever heard the names Ima Hogg, Shanda Lear, or North West. Half the fun of naming people is giving them punny names. The other half is calling those punny names afterward, especially if you can embarrass those people in front of their friends.

    Instead of naming people or Sims, though, we're going to name and call variables, which is fairly simple. All you have to do is type their names. Take a look at this program:

    # define tortoise variable
    tortoise = 42
        
    # call tortoise variable
    tortoise

    That last line calls or brings up whatever value tortoise currently stands for. Seems straightforward, right?

    Take another look and think back in the mists of time, all the way back to Unit 1. Based on what you learned in that first week, do you see anything missing?

    If you run a program with that command, you're not going to see anything print for the value of tortoise. This is for the very simple reason that you didn't use the print function.

    This is yet another example of how computers are both very smart…and kinda stupid. The computer will call up tortoise, all right, but without print() that 42 value's just going to sit there in its memory. When you ask why it didn't tell you what tortoise stands for, your computer will reply with the classic passive-aggressive, "You didn't ask."

    Yeah, okay, the whole conversation with your computer won't happen. If you ask it a question, it's just going to sit there. It won't display the variable unless you print it. That goes for any more complicated stuff you do with your variables, too.

    Anicrement and De-anicrement

    Now that we can call variables, let's try something more ambitious. Remember that example from the last lesson about Anakin and his switch to the Dark Side?

    Last time, we talked about starting good ol' Anakin off with:

    Anakin = 1

    Later on, when his transformation's complete, they'll change his value to 0 to represent how he went all angsty and evil.

    Anakin = 0

    When you made your own fictional characters, you used that same syntax with the equals sign to assign your variables some unique, character-defining values.

    Just like variables themselves, you may recognize that equals sign from Math class. In math, an equals sign shows that two values are equal. If you write the following equation, you're saying that the expression on the left is equal to the number on the right.

    2 + 2 = 4

    They just are equal, and there's no argument about it. In Python, that equals sign means something a little different. When you say Anakin = 1, you're creating a value where there wasn't one before. That means you can set that value to anything you want—within some basic rules, of course. You can't say the following:

    2 + 2 = 5

    Python likes math a lot; it doesn't want to change the laws of mathematics. However, you can follow the rules of variable naming and say the following:

    two_plus_two = 5

    This time, it will be 5. Instead of bowing to the power of reality, you're shaping reality for yourself. It's a bit of a power trip.

    But notice how this equals sign is being used for variable assignment—not for changing laws of math.

    The Variable's Reset Button

    Because you can make a variable equal a value once, you can use the same equals sign to make it equal to something else later on. If you assigned it, you can reassign it. That's one reason variables are so useful.

    That's exactly what we'd want to do in the Anakin example. To recalculate the fate of the galaxy itself (or someone else's galaxy, really), all we have to do is reassign our variable:

    Anakin = 0

    You can reassign variables at any point in your program. Just throw in a line of code like the one above anywhere and from that point forward anything that works with the variable will use the new value.

    Emphasis on the, "From that point forward," part of the statement. Changing a variable partway through the program won't change its value before that point. You have to know when to reset the variable value to get the result you want.

    The last piece of advice we have is obvious, but can still be tricky: always proofread your own code. If you start with Anakin = 1 and later redefine it as anakin = 0, Python will count those as two separate variables. Make sure your variables are spelled and capitalized exactly the same throughout your program. Otherwise, Anakin might still count as a Jedi. Not. Good.


    Sample Lesson - Activity

    Activity 2.02: The Plot Thickens

    In Activity 2.1, you created a set of variables to describe some of the main characters in a story you love. A list of characters doesn't have quite the same spark, though. It's missing something, like…the reason you'd actually read the story. You know, the plot.

    You'll be adding in some plot to that code right now. Don't worry: we won't have you reproduce the book in Python print statements. Instead, we're thinking about how a good plot involves change. Whether it's

    • a war story,
    • a coming-of-age novel,
    • a romantic comedy,
    • a romantic coming-of-age comedy in the middle of a war,

    the main characters experience conflicts and growth. That only happens when something about the characters change. Entirely coincidentally, you've just learned how to change the values of your variables. Wonder how that's going to fit together. Hmm. Hmmmm.

    You're not going to just wade in and change all your character variables willy-nilly, of course. You need some kind of plan. We'll walk you through it like the wise mentor in a novel where you learn to program variables in Python.

    Step One

    First, look at the variables you chose to define your characters. Think about what those variables are at the beginning of your story. Age, Hogwarts House, faction, elemental power—whatever you've got, set your characters up to have the appropriate values when the story starts. (Remember, your variable values can be numbers representing non-numerical values if you give comments about what the numbers mean.)

    Then, think about what changes during the story. Does someone have a birthday? Does someone change allegiances from one faction to anther? Does someone dye their hair pink? What's different by the end?

    Write down the variable values that you'll need to change to reflect the character changes during the course of the story. You'll probably have at least one variable change per character.

    If nothing changes for anyone, come up with at least one new variable that does change. It's either that or write the author, trying to convince them that they need to rewrite their story so that the main character dyes their hair to be more punk rock. You can do that but…it's probably not going to happen. Just add in a new variable.

    Step Two

    In PyCharm, open your Python file from Activity 2.1. You should be looking at that lovely block of character-defining variables.

    Now, check out the values you set for those variables. Set them to what they would be at the beginning of the story.

    Step Three

    After your block of variables, write (and comment, of course) code that calls and prints each variable in turn.

    Here's how this might look for Cato the Career Tribute in our Hunger Games example:

    # Variables: each character's age, home District, survival
        
    # Cato (beginning)
    cato_age = 16
    cato_district = 2
    cato_survival = 1 
        
    # calling variables for Cato at beginning
    print("Cato's starting age is",cato_age)
    print("Cato's starting District is",cato_district)
    print("Cato's starting survival status is",cato_survival)

    Check out we didn't just call the variables themselves, but we also used our knowledge from Unit 1 to add some explanatory text that prints along with the variable. (Remember, print() can print multiple values separated by commas.) This isn't strictly necessary, but it helps you keep variables straight when you're printing a bunch of them at a time.

    Actually, you know what? It's necessary. Add in the explanatory text telling us what the variable represents. Your grader will thank you.

    Step Four

    Copy and paste that whole block of variables and calls, placing it after the first part. Change it so the comments and the variable values reflect the characters at the end of the story. Again, here's Cato for reference:

    # Cato at the end (after he dies horribly)
    cato_age = 16
    cato_district = 2
    cato_survival = 0 
        
    # calling variables for Cato at end
    print("Cato's final age is",cato_age)
    print("Cato's final District is",cato_district)
    print("Cato's final survival status is",cato_survival)

    Don't forget to change the text in the print statements so that they're accurate at the end of the story. Otherwise, those print statements are going to get really confusing really quickly.

    Step Five

    Run your code to make sure it works. You should end up with output that prints your variable values for the beginning and end of your story, with some explanatory text to keep the different values straight if you want. If it doesn't, check your variable declarations, print function calls, and comments that might not have actually been commented out.

    Once it's good to go, save your changes to the file.

    Step Six

    Write a .txt file with four to six bullet-point-style notes to explain the changes you made to your variables over time and what they represent. They don't have to be super in-depth, but please give us complete sentences. For example, when we write about Cato, we'll say:

    • Cato's age and district don't change because he dies before his next birthday and, uh…nobody can change their district in the series.
    • What does change is his survival status. Poor Cato.

    Step Seven

    Save your list and zip it up with your Python file. Then submit both of them below, just like uzh.