# Beginning with python

## Why start with python?

Python is a fantastic language to start learning coding with. It's has a nice learning curve and is incredibly versatile, and is easy to read and write. Below is an example of a python programme that outputs the statement `Hello World!`.

{% code title="hello-world.py" %}

```python
print("Hello World!")
```

{% endcode %}

## Introduction

Python is used for many reasons. It is used for:

* server-side web development
* software development
* mathematics, and
* system scripting

People use python because it works on different platforms, such as Linux, Mac, Windows, Raspberry Pi, etc, and has a simple syntax that's similar to plain English. Python has a syntax that allows developers to write programs with fewer lines than some other programming languages. Python runs on an interpreter system, meaning that code can be executed as soon as it is written. This means that prototyping can be very quick. And it can be treated in a procedural way, an object-oriented way or a functional way, making it suitable for all developing styles.

Python also relies on indentation, using whitespace, to define scope; such as the scope of loops, functions and classes. Other programming languages often use curly braces for this purpose.

## Installing Python

You can install the most recent python version on almost all operating systems by visiting <https://www.python.org/downloads/> and downloading the most recent binary.

You can now check your installation by running `python3 --version`.

And now you can run the following to run your *hello world* program.

```python
python3 -c "print('Hello World!')"
```

Now you can move onto the next page

## Setting up the `py` alias

Writing `python3` every time you want to run a snip of python code, or a python file, can be tedious. The whole point of python is to be as efficient and streamlined as possible. So, obviously it would be much more convenient to just type the simple `py` rather than `python3`. Especially for repeated tasks.

And like everything to do with python.... setting up the alias is easy to do.

{% tabs %}
{% tab title="Linux" %}
Edit the \~/.bashrc file (`nano ~/.bashrc`) and add the following line to the bottom of it.

```shell
alias py="python3"
```

{% endtab %}

{% tab title="Mac" %}
Edit the \~/.bashrc file (`nano ~/.bashrc`) and add the following line to the bottom of it.

```shell
alias py="python3"
```

{% endtab %}

{% tab title="Windows" %}
&#x20;<img src="https://1019632161-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFTPM3hMdhCJRGAnPim%2Fuploads%2Fv6G3bWclCr7AZEGYlQdZ%2Fimage.png?alt=media&#x26;token=97554658-74d5-4c84-9d9f-befed2bfb946" alt="" data-size="original"> Select this option when installing python...&#x20;

If you haven't selected it already, just rerun the installer, and select the *Modify* option.
{% endtab %}
{% endtabs %}
