You'll learn **three** things at the same time so don't get discouraged if it feels a bit much at the start.
Everybody's issues will be in these three different domains and at the beginning it can be difficult to differentiate between them.
Keep this in mind, everybody has to go through this stage and the *click* comes at different times for different people but everybody clicks at some point!
The three new things you'll learn:
1. the **concepts** of programming, most notably Object Orientated Programming (OOP)
2. the **syntax** of one particular language, in our case Python3
3. the **tools** needed to start programming in our language of choice
Within each of these topics there are *subtopics* but there are not bottomless!
Below is a small overview of how I would subdivide them.
## Concepts
The subtopics behind the concept of programming can be sliced (in no particular order) as follows:
The concept behind these topics are the same in most languages, it's just *how* you write them that is different.
This *how* is part of the **syntax** of the language.
## Syntax
> In computer science, the syntax of a computer language is the set of rules that defines the combinations of symbols that are considered to be correctly structured statements or expressions in that language.
> This applies both to programming languages, where the document represents source code, and to markup languages, where the document represents data.
> The syntax of a language defines its surface form.[1] Text-based computer languages are based on sequences of characters,
The quote above is taken shamelessly from [wikipedia](https://en.wikipedia.org/wiki/Syntax_(programming_languages)).
## Tools
### Writing code
Scripts are text files, plain and simple.
So in order to **write** a Python3 script all we need is a text editor.
Nano, vim, notepad++ all do a good job of editing plain text files but some make it *easier* than others.
You've noticed that vim colors the code of a shell script no?
One of the many features of an [IDE](https://en.wikipedia.org/wiki/Integrated_development_environment) is *syntax highlighting*.
It colors things such as [keywords](https://realpython.com/python-keywords/) which makes our life so much nicer when writing code.
We'll come back to these features in a bit.
### Running code
In order to **run** Python3 code you need the Python3 interpreter.
This is because when you **execute** your script, the interpreter will **read and execute** each line of the text file **line by line**.
Most people who want to write and run Python3 code, or any language for that matter, will install an Integrated Development Environment to do so.
There are no *rules* as to what has to be included for a program to qualify as an IDE but in my opinion they should include:
* syntax highlighting
* autocomplete
* *goto* commands such as goto definition, goto declaration, goto references
* automatic *pair* opening and closing
* builtin help navigation
There is a plethora of IDE's available and you can't really make a *wrong* choice here, but to make the overall learning curve a bit less steep we'll start out with a user friendly IDE, [pycharm](https://www.jetbrains.com/help/pycharm/installation-guide.html).
# The python3 shell
TODO animated overview of the shell and the world of OOP
The `True` and `False` you see are also objects but of the type `bool`.
If you want to read up a bit more on boolean logic I can advise you [this](https://en.wikipedia.org/wiki/Boolean_algebra) page and also [this](https://realpython.com/lessons/boolean-logic/).
This boolean logic open the door towards **conditional logic**.
Let's convert the quote below to logical statements.
> If you are younger than 27 you are still young so if you're older than 27 you're considered old, but if you are 27 on the dot your life might be at [risk](https://en.wikipedia.org/wiki/27_Club)!
```python3
age = 35
if age <27:
print("you are still very young, enjoy it!")
elif age > 27:
print("watch out for those hips oldie...")
else:
print("you are at a dangerous crossroad in life!")
⛑ **Do not fight the automatic indentation in your IDE! Pycharm is intelligent enough to know when to indent so if it does not indent by itself, you probably made a syntax error.**
We can use conditional logic to create quite elaborate decision processes.
Let's build a mini text based adventure game.
Granted it's not a *tripple A* game but it will train your `if` and `else` skills plus it will highlight some issues we'll overcome in the next section.
I urge you to read up on some [best practices](https://www.tutorialdocs.com/article/python-conditional-statements-tips.html) for `if` statements.
We will not improve on this particular example but I do advise you to create a similar style game during one of the workshops once we have learned some new tricks.
As an extra challenge you could return a [multi line string](https://www.askpython.com/python/string/python-multiline-strings) and print it outside of the function!
There is no need to reinvent the wheel each time you build a bike.
The same goes for programming.
Most, if not all, programming languages come with a **standard library** which is a collection of additional objects and functions to facilitate common problems.
We'll look at some essential ones together but I urge you to [read](https://docs.python.org/3/library/index.html) up a bit when you have some free time.
Over the course of you programming journey you'll discover that efficient programming is often finding the right libraries and chaining them together to suit your use case.
Imagine we want to include a dice in our text based adventure game.
How on earth do we program that?
We need some for of *randomness* in our code.
A [quick google](https://stackoverflow.com/questions/28705965/python-random-function-without-using-random-module) demonstrates this is quite difficult without the use of libraries.
As randomness is both [extensively](https://www.random.org/randomness/) used in programming **and** it's quite [difficult](https://medium.com/swlh/random-functions-a4f36b1dfd8f) to do properly, you'll find a `random` library in most languages.
The new **keyword** you'll learn here is `import`.
It allows you to add extra functionality to your program.
Once *imported* we can **call** functions that exist from the library in question.
So, our dice becomes as follows.
```python3
import random
throw = random.randint(1, 6)
print(throw)
```
⛑ **Autocomplete is your friend. You can use it to browse around a library and discover interesting functions or classes you can make use of.**
A second widely used library is `datetime`.
It facilitates handling dates, hours, calendars, time differences, etc.
A simple program we can write to illustrate it's purpose is a *will-it-be-Sunday* program.
You give date and the program tells you if it's a Sunday or not.
```python3
import datetime
sunday = 6
date = input("which date should I look up? (example: 2022 3 23) ")
year, month, day = date.split()
date = datetime.date(int(year), int(month), int(day))
if date.weekday() == sunday:
print("yes! you can sleep in...")
else:
print("better set your alarm")
```
The program above incorporates a lot of different concepts.
Read it very slowly and think about what each step is doing.
Also think about how you can *break* this program!
⛑ **Why on earth is Sunday six? Read the [doc](https://docs.python.org/3/library/datetime.html#datetime.date.weekday)!**
[Memento Mori](https://en.wikipedia.org/wiki/Memento_mori) is a bit of a grim concept and if it freaks you out, maybe adjust the exercise to calculate the days until your next birthday.
That being said, we all die and we all live in a country with a life expectancy.
The [Belgian](https://www.healthybelgium.be/en/health-status/life-expectancy-and-quality-of-life/life-expectancy) life expectancy for a man is about 80 years so if you know your birthday, which you should, you can calculate your theoretical death day.
Plus, you can calculate the percentage of your life that remains.