Getting started

In this section we will write our very first program, and install what's needed to start programming on our own computers.

IDLE

The programming language we will be using is called Python, and is one of the largest programming languages in the world.

IDLE stands for Integrated Development and Learning Environment and is a way to write code on your own computer.

You can also write code and try all examples right here on Mathplanet.com. It's particularly suited for trying out new things. The advantage of coding on your own computer is the option of saving code for next time, and continuing to work on things after you've left this site. But it's completely up to you!

Python works on different operating system (Windows, Mac, and Linux). You can download it for free here:

https://www.python.org/downloads/

It's possible you already have Python installed, in that case you should ensure it's version 3 or later.

You can watch the video at the end of this section to see what the installation process is like.

My first program

In this box you can write Python code - there will be a similar one on almost all upcoming sections:

Try writing the following in the box above and pressing RUN (the "play" button):

print(1+1)

You will see the computer understands your mathematical expression and prints the answer "2".

You can keep editing the code and running it again. If you can't see the code, click Edit (the button that looks like a pen).

online python compiler matteboken

On your computer

If you want to do the same thing on your computer without this website you need to install Python and IDLE. The advantage of having it on your own computer is the option of saving code for next time, and continuing to work on it even after you've left this site. But it's completely up to you - and if you don't want to install anything you can skip this part.

Open IDLE on your computer.

Enter the following code and press ENTER:

1+1

It looks like this:

integrated development and learning environment - idle program

Try some other calculation methods!

From a file

Just like a baking recipe we can write instructions in advance, and ask the computer to carry all of them out, in order.

Then we first need to create a new file. Go to the IDLE menu, File and select New File:

File -> New File

Enter the following lines and save the file somewhere on your computer:

print("Hello")
print("How are you?")
print("I'm fine.")

NOTE! You can use the copy button (kopiera koden) that appears below the code at the bottom right to copy the code and paste it into your file.

Then go to the IDLE menyn, Run and select Run Module.

Run -> Run Module

You should now see the program writing out all three lines of text on your screen.

We can at any time close the program and return to this code by the menu IDLE menyn File -> Open.

Read page in other languages

In this video we explain two different ways to run your python code. Either how to run the code directly on Mathplanet.com or how to install idle on your computer (windows) to run the code there.

  • Programming language: A language used to create computer programs and apps. There are many, such as JavaScript, Python, and C++.
  • Python: One of many programming languages, and what we use in this course.
  • IDLE: Integrated Development and Learning Environment - a program on your computer used for writing and testing Python code.
  • Operating system: The main program that governs a computer's resources and distributes them among other programs on the computer, including the ones you make. Common alternatives are Windows, Mac OS, Linux, Android and iOS.