adds flowchart

This commit is contained in:
waldek 2022-05-02 16:22:33 +02:00
parent 46fe6d8276
commit 31be912721
2 changed files with 31 additions and 12 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

View File

@ -65,6 +65,22 @@ TODO animated overview of the shell and the world of OOP
# Installing pycharm # Installing pycharm
Depending on the platform you use, you can install Pycharm in multiple ways.
The computers in the classroom come with Pycharm installed but if you want to continue working from home you can follow the instructions [here](https://www.jetbrains.com/pycharm/download/#section=windows).
If you run Windows at home you will probably need to install python as well.
Download the latest version from [here](https://www.python.org/downloads/).
On Linux and Mac OSX there will probably be some version of python installed.
From a terminal you can check the version that's installed by executing the following commmands.
```bash
waldek@metal:~$ python3 --version
Python 3.9.2
waldek@metal:~$
```
## Virtual environments
TODO TODO
# Your first project # Your first project
@ -209,7 +225,7 @@ But how can we **get** some information from the user?
This is done with the built-in `input` function. This is done with the built-in `input` function.
If we open up a python shell we can observe it's behaviour. If we open up a python shell we can observe it's behaviour.
```python3 ```python
>>> input() >>> input()
hello world hello world
'hello world' 'hello world'
@ -436,7 +452,7 @@ You should do this in a **new** python file.
I suggest you call it `c_to_f.py` or something that makes sense to you. I suggest you call it `c_to_f.py` or something that makes sense to you.
The result of this program *could* be as follows. The result of this program *could* be as follows.
```bash ```
➜ ~ git:(master) ✗ python3 ex_celcius_to_fahrenheit.py ➜ ~ git:(master) ✗ python3 ex_celcius_to_fahrenheit.py
What's the temperature?30 What's the temperature?30
30°C equals 86.0°F 30°C equals 86.0°F
@ -1184,19 +1200,17 @@ while counter <= 10:
print("after the loop, counter: {}".format(counter)) print("after the loop, counter: {}".format(counter))
``` ```
<details>
<summary>Another example</summary> Or with only variables and a more verbose way of incrementing the numbers.
```python3 ```python3
FirstValue = 2 first_value = 20
SecondValue = 0 second_value = 0
while FirstValue>SecondValue: while first_value > second_value:
print("The second value is bigger") print("second value {} is smaller than {}".format(second_value, first_value))
SecondValue = SecondValue + 1 second_value = second_value + 1
``` ```
</details>
Two *extra* things might look new to you here. Two *extra* things might look new to you here.
First the `import time` and `time.sleep(1)`, can you tell me what it does? First the `import time` and `time.sleep(1)`, can you tell me what it does?
Next the `counter += 1` which is called [incrementing](https://stackoverflow.com/questions/1485841/behaviour-of-increment-and-decrement-operators-in-python). Next the `counter += 1` which is called [incrementing](https://stackoverflow.com/questions/1485841/behaviour-of-increment-and-decrement-operators-in-python).
@ -1247,12 +1261,17 @@ print("after the loop, counter: {}".format(counter))
Infinite loops are a cornerstone of modern programming. Infinite loops are a cornerstone of modern programming.
While they might look scary, don't overthink it, you'll get used to them very quickly. While they might look scary, don't overthink it, you'll get used to them very quickly.
Logical procedures can be drawn out with flow charts.
An example can be seen in the image below.
[flowchart while loop](./assets/flowchart_while_01.png)
⛑ **When testing out an infinite loop it's sometimes handy to insert a `time.sleep` in it to slow down the execution a bit so you can wrap your head around what's happening.** ⛑ **When testing out an infinite loop it's sometimes handy to insert a `time.sleep` in it to slow down the execution a bit so you can wrap your head around what's happening.**
🏃 Try it 🏃 Try it
--- ---
Go back to the Celsius to Farenheit converter and add a while loop to ensure the user puts in only numbers. Go back to the Celsius to Fahrenheit converter and add a while loop to ensure the user puts in only numbers.
# Coding challenge - Guess the number # Coding challenge - Guess the number