Main content
Course: Intro to computer science - Python > Unit 1
Lesson 1: The programming platformUsing the development environment
Get to know the features of the Khan Academy programming platform. Learn how to use the code editor and the console, how to create spin-offs, and how to ask for help.
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.
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.
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. We can then click (or use the up and down arrow keys) to select a suggestion.
You may not recognize many of these suggestions just yet, but as our programs get larger, we'll start to rely on them more. For example, as our Python vocabulary grows, we 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?
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. Think of this like handing in an assignment; we're telling the computer that we're ready for it to take a look now. In this case, though, there's no penalty for mistakes, so we should run our program early and often!
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
We designed these features specifically for the Khan Academy IDE, with learners like you in mind!
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 public learner-created programs, as seen in the program galleries, and on all course 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.
Getting help
Ask the community
If you're stuck, you can always ask for help from the Khan Academy community. The community can help track down tricky errors, suggest ways to improve your code, or brainstorm how to build a specific feature.
To request help on a Challenge bonus or a Project, you first need to create a spin-off. This makes your program code publicly visible so that others can see what you're working on. Then, navigate to the Questions tab on your program page and submit a help request.
The Khan Academy community will then make their best effort to answer your question. As you grow your Python experience, you can join in by answering other people's help requests, too! To see all unanswered help requests, press the Help requests button on the course home page.
Ask Khanmigo
If you have access to Khanmigo, Khan Academy's AI-powered tutor, you can ask it for programming help. On any Challenge or Project page, open the Khanmigo chat window and start a conversation!
Khanmigo can see both the instructions and your code and offer suggestions based off of them. For example, you can ask, "Help me with this error," or, "Where do I start?" As you make changes to your code, Khanmigo keeps up and can offer personalized help based on where you are in the programming process.
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 + ↓ |
*
Want to join the conversation?
- I find this hard and confusing will there be videos?(2 votes)
- There will be; however the course is under development currently so there is not much learning material.(7 votes)
- I never done this before. What is a variable?(2 votes)
- You can imagine a variable as a box that stores a value.
a = 5, will create a variable(box that stores a value). And then it will put inside that box 5. If you find this still confusing, you may need to wait for actual videos and articles to come as helper/educational material as it is not available right now.(6 votes)
- Why doesn't the Python editor have Oh Noes?(2 votes)
- Python is a completely different language than Javascript and HTML so it has a different way of expressing errors.(3 votes)
- Do IDEs (like Python3 IDE) come with autofill, syntax highlighters and linters by default, or is that something I would need to find a third party for?(1 vote)
- It depends on your IDE, but most will include syntax highlighting and auto-complete. Not all of the have a linter, like KA has, but many do.
I'm not sure, but I think the Python IDLE does include those features.(3 votes)
- I can't understand this part very well. Is there any other guides which can help me through this excercise?(2 votes)
- Not likely - the Python environment is new to KA so I don't think you'll be able to find many other resources. Of course, there's many people here who go through community questions daily, so if you are confused about anything specifically, don't hesitate to ask!(1 vote)
- I have a question; how I replace my name with the word learner(2 votes)
- you enter your name instead of a word learner(1 vote)
- Is there a multimedia library like "pygame" or "turtle" that can be used for game dev?(1 vote)
- I think the version of Python that KA uses is some form of pyodide. I tried myself to import turtle and it gave me an error message saying that Turtle is not supported. Tkinter is another module that is similar to what you are talking about, but sadly it also does not work in the KA console.(1 vote)
- How to put users name. I don’t know 🤷♀️ I just need help.(1 vote)
- You can ask for the users name, store it in a variable, and use it.
name = input(“What is ur name?”) #this asks for the name of the user and stores it in a variable, called name.
print(“Hello, “ + name + “!”) #this displays the name
Hopefully this helps!(1 vote)
- How do you use inputs?(1 vote)
varName=input("string ")
, wherevarName
is the name of your variable and"string "
is the question you're asking. The space at the end isn't required, but it makes the program look cleaner.(1 vote)
- Hi people,
I want ask you about URL challenge step2, I really don't get what is needed(0 votes)- You need an
input()
function asking for the subject. For example:subject=input("Enter the course you are taking. ")
Hope this helps!(1 vote)