Where to begin with Python
In this tutorial you will learn to install and run Python on either Mac, Windows, or Linux.
Python is able to run on multiple platforms as it is a cross-platform language. Best of all is that it is free and open source! We love free and open source. Now the only thing about Python is that there are versions Python 2 and Python 3. For This tutorial we will be using Python 3. Mac has Python 2 preinstall but you can still install Python 3 and hopefully Apple will turn everything over to Python 3 in a future update. It is also always a good idea to update the version of Python you have to the current version.
How to run Python
So first we need to see which version of Python we have on our computer. For this we will be using command line. Do not be afraid, command line is just like using a computer but you do not have a mouse. I will have a tutorial on how to get more comfortable with the command line at a later date.
-
First open your command line prompt.
![name of picture]()
-
Then type
python --version. This will print out the version you have for Python 2.![name of picture]()
-
To see if you have Python 3 installed then you can type
python3 --version.![name of picture]()
See terminal is not all that bad! It is actually pretty fun. Next we will use the terminal to do some super basic Python writing! Super basic like 2+2 just to give you a taste and then we will move into installing an Integrated Development Environment, also called an IDE.
-
Open up your command line prompt again. Then type
python3press enter. That is if you had a version appear for Python 3 show. If you did not then just typepythonand press enter.![name of picture]()
-
Then type
x=2press enter and typey=2press enter.![name of picture]()
-
Then we will add the
xandyby typingz=x+ythen press enter.![name of picture]()
-
Now you have told the computer to take the value you have
xset as, which in this case is2. Then take the value you set foryand add them together. This number is set to the variablezand we will talk more about variables later. -
Next type
print(z)and press enter.![name of picture]()
-
Ta-Da! You have now have
4on your screen! Python and really most programming languages are fundamentally this easy. Though Python is even easier to learn due to its scripting ability. -
To get out of Python type
exit()and press enter.
Installing an IDE
The purpose of installing an IDE is to provide an environment that will help you code. My personal opinion is that an IDE should come light weight which basically means that you only have what you need installed.
-
We will be using Vistual Studio Code.
-
Install
VSCodeto your computer. -
Create a folder to hold all your wonderful Python programs!
-
Open up
VSCodeif you have not done so already. This is what you should see.![VSCode first time]()
-
Next is to click the file button on the top left and side of the window. Then click
Open Folder. Go to where you made your Python folder and select it.![Opening folder]()
-
After that you will want to click the little button that looks like a file with a plus symbol to the right of your folder. Then name your first program
helloworld.py.![Naming first program]()
-
Now you should see a popup in the bottom right and corner asking to install python 3 if you do not already have it installed. Click this and it will install it and it will automatically select it as your interpreter. An interpreter is what executes what we write in the IDE which I like to call “human code” because we are able to read it. Then the interpreter takes our code and directly executes the code without having to translate it to a machine language.
![Installing python 3]()
-
When you type
print()then hover over it, you will get a tool tip on how you can useprint. This is the power of an IDE. They help you out when you mess up typing something or help you learn what can they can do.![Using print]()
-
In your program you want to type
print("hello world").![Code for hello world]()
-
Then press the green arrow in the top right hand corner. Now you should see a screen popup at the bottom of your screen that says
hello world.![Running program]()













