Free preview Computational thinking with variables

The programming platform

Meet the Python programming environment.

๐Ÿ“„ Course overview

In this course, youโ€™ll use programming as a tool to design recommendation engines, simulate natural selection, invent game levels, and more. Through lessons designed with beginner programmers in mind, you'll learn how to read and write Python programs - no prior computer science experience required!

A practical approach

In designing this course, we focused on the skills you need to start building meaningful programs now. You'll see a focus on problem solving and program design over computer science theory.

We also emphasize reading and working within existing code. There will be few cases where you'll see a blank screen and be asked to write a program from scratch. Programmers reference, reuse, and extend code in almost everything they do, so we think new programmers should, too!

What you'll learn

This course covers programming fundamentals in Python, including:

  • Data types, expressions, and variables
  • User input
  • Boolean logic and conditionals
  • Loops
  • Modules and module imports
  • Functions
  • Lists
  • Dictionaries
  • Objects

Each unit introduces a new theme, like simulations or game design, so you can explore some of the many applications of programming along the way.

How you'll learn

[[โ˜ƒ video 1]]

This course includes three types of practice materials:

  • In Exercises, you'll practice reading programs.
  • In Challenges, you'll practice modifying programs.
  • In Projects, you'll design your own programs.

Exercises

Exercises are multiple choice problems that focus on tracing how a program executes and translating user requirements into code. When practicing a new skill, we recommend you start with the associated Exercise.

Challenges

Challenges are guided programming assignments in which you'll modify or extend an existing program. They provide step-by-step instructions and use automated evaluation tools to provide feedback along the way.

Projects

Projects are open-ended programming assignments that serve as the capstone for each unit. They provide a broad outline of a problem to solve and a rubric with a set of requirements, but the rest is up to you!

Frequently asked questions

Who is this course for?

This course does not assume any prior programming experience, so it's suitable for complete beginners! It targets a high school level, but we also recommend it for adult learners or motivated middle school learners who want to learn how to code. It does not require a math background aside from basic arithmetic.

Is this course standards-aligned?

This course most closely matches the AP CS A learning objectives, but uses the Python programming language instead of Java. Due to the difference in languages, it is not recommended as a supplement for students in an AP CS A class, but rather as an alternative introductory computer science curriculum.

Should I learn Python or another programming language?

Python is one of the most popular programming languages in the world. We recommend Python for first-time programmers because its syntax mirrors English, making it easier to understand and use.

Ultimately, it doesn't matter which language you learn first. The programming concepts we cover - like variables, conditionals, and loops - apply to all programming languages. Once you learn the basics in one language, you'll be able to pick up another language much more quickly!

How can I use this course in my classroom?

Check out our Teacher resources unit for support in implementing this curriculum, including a video course tour.

What version of Python does this course use?

Our programming platform uses Python 3.

๐Ÿ“„ Using the development environment

So, we're ready to start programming, but how do we do that? Let's get set up with the right programming equipment.

Using a development environment

Most programmers use integrated development environments (IDEs) to create their programs. IDEs combine tools for writing, running, and testing code into a single platform to make it easier and faster to get our work done.

For this course, we'll be using Khan Academy's online Python IDE.

[[โ˜ƒ explanation 1]]

Writing code: the code editor

The first thing we'll need is somewhere to write code. A code editor is a text editor specialized for a programming language.

Code editors work just like your favorite docs app. We type in it and text appears - nothing fancy here. But, instead of English, its built-in tools observe the rules of a particular programming language.

[[โ˜ƒ image 5]]

Syntax highlighter

You'll notice that different words, numbers, and symbols appear in different colors. This is called syntax highlighting. The code editor uses colors to make it easier for us to distinguish between different components of our program.

Imagine if your docs app colored all nouns green, all verbs blue, and all adjectives orange. That's what the syntax highlighter does, but for different elements of the Python language.

Linter

A linter is like Python spell check. If we type something it doesn't recognize as valid Python syntax, it'll underline it and pop up a symbol in the left sidebar. If we hover over that symbol, it'll show a message explaining the issue.

Notice that there are two types of symbols: a red circle means error and a yellow triangle means warning. Errors mean our program is broken or invalid. Warnings help us write programs with good style and clarity, like a writing assistant. They'll warn us of things like, "Hey, this is an odd place to put this," or, "Hey, this line is really long and hard to read."

Autocomplete

If we start typing in the editor, we may see a dropdown pop up with suggested words. This feature autocompletes common Python keywords and names, so we don't have to memorize them all.

You may not recognize many of these suggestions just yet, but as your Python vocabulary grows, you may want help remembering: was that thing I needed called len() or length()?

Running code: the console

Now that we've written our program, what do we do with it?

[[โ˜ƒ image 4]]

At the top of the IDE, you'll see a big green Run button. When we press Run, it submits the program to the computer to execute. This tells the computer we're ready for it to try out our instructions.

As it executes the program, the computer displays any results in the console. This output then stays displayed in the console until the next time we press Run - it does not automatically update.

Console output might be a result that the program asked the computer to display, or it might be an error that the computer encountered while executing the program. Not every program has output, so it's also possible the console stays empty.

Programming on Khan Academy

To open up the Khan Academy IDE, navigate to the course home page and press the 'Create a new Python program' button at the top. You can view all the programs you've created by pressing the 'View my programs' button.

Spin-offs

The spin-off feature allows you to make a copy of a program, while still giving credit to the original creator. This is a great opportunity to experiment with programs that you're curious about or build off of programs that you're inspired by. Changes you make to the spin-off program are entirely your own; they won't affect the original program.

The Spin-off button is available on all course code examples and Projects. The Spin-off button unlocks on a Challenge after you complete it.

When working on bonuses or creative extensions within the course, we recommend creating a spin-off first so that you don't risk breaking your Challenge or Project solution as you explore.

Keyboard shortcuts

The code editor supports a number of keyboard shortcuts to make it easier to navigate.

Action | Mac | PC

  • | - | -
    Undo | Cmd + Z | Ctrl + Z
    Redo | Cmd + Shift + Z | Ctrl + Y
    Copy | Cmd + C | Ctrl + C
    Paste | Cmd + V | Ctrl + V
    Select all | Cmd + A | Ctrl + A
    Find | Cmd + F | Ctrl + F
    Save* | Cmd + S | Ctrl + S
    Move cursor to start of line | Cmd + โ† | Ctrl + โ†
    Move cursor to end of line | Cmd + โ†’ | Ctrl + โ†’
    Move cursor to start of file | Cmd + โ†‘ | Ctrl + โ†‘
    Move cursor to end of file | Cmd + โ†“ | Ctrl + โ†“
    Comment out lines | Cmd + / | Ctrl + /

*[[โ˜ƒ explanation 1]]

Enjoying the free preview?

Lessons after number 3 are reserved for Pro members โ€” unlock the full course and every other one.

Sign up free Go Pro