New around here? Read Using this Website. You can also click here to create an account or log in.
This website teaches computer programming. This skill is very useful: with programming you can automate computer tasks, make art and music, interpret and analyze survey results, build tools for other people, create custom websites, write games, examine genetic data, connect people with each other, and the list goes on and on.
If you would like a more gradual, video-based presentation to Python, you may want to examine Python from Scratch, offered by the University of Waterloo. There is also a video series on Language Independent Programming Lessons which can be a useful supplement.
Here is the first line of Python code in our lessons.
When you run a program you also get to see the output. The example program above only has one command,
print("Hello, World!") and it created one line of output,
Here is an analysis of this first program:
- The parentheses
()after the print command are used to contain what you want to print.
- The quote marks
" "are used as a container for the text
Hello, World!inside. Without quotes, Python would think that
Hellowas meant to be a command. This would be cause an error since no such command exists.
You will learn more about the different pieces of a Python program as you progress through these lessons.
Let’s see exactly what happens when we leave out the quotes.
Here, the program crashed: this means we gave a bad command to the computer, causing an error and forcing it to stop.
Our first exercise is given below. It asks you to write a program similar to the first one above. Type your program into the box, and when you want to test whether your program correctly performs the task, press the Run program button. If you don’t get it correct on the first try, edit the program and try running it again.
Tip: you can make the code box look taller by dragging its bottom border.
If you have created an account and logged in,
- we will save every version of the code that you run;
- History shows you all versions you have submitted so far;
- and when you visit the site again, the most recent version appears in the editor.
Once you get an exercise like this correct, you will see a checkmark appear in the top right corner of the box. If you are logged in, the Computer Science Circles website will remember which exercises you complete.
|These lessons teach Python version 3. While our lessons aim to be self-contained, if you decide to search online for other information about Python, be aware that Python version 2 is also commonly used and is incompatible in some ways.|
Once you are ready to go to the next lesson, click the Next button below.