This commit is contained in:
Nils Pukropp
2024-09-16 21:02:27 +02:00
commit b907cb789e
83 changed files with 5845 additions and 0 deletions

View File

@ -0,0 +1,140 @@
# Zusammenfassung der Vorlesung
## Variablen und Zuweisungen
```python
variable = 42
print(variable)
print(variable + variable)
```
- Case-Sensitive
- A-z, 0-9, _
- Keine Schlüsselwörte
### Kurzzuweisung
Operationen und Zuweisung können in einem Schritt durchgeführt werden mit `${Operation}=`
```python
number = 42
number **= 42
assert number == 42 ** 42
number += 42
assert number == 42 ** 42 + 42
```
---
## Assert
- Erwartet einen wahren Ausdruck, wenn dieser nicht erfüllt ist gibt es einen Fehler
- Gut um etwas schnell zu testen
```py
number = 42
assert number == 42
bigger_number = number ** number
assert number ** number == bigger_number
```
---
## Typen
```py
number = 42
string = '42'
assert number != string
```
---
## Funktionen
### Standardfunktionen
- Typen konvertieren
```python
>>> int(2.6)
2
>>> float(2)
2.0
>>> str(2.0)
'2.0'
>>> type(2.0)
<class 'float'>
```
- Input/Output
```python
>>> input("Hier Input geben: ")
Hier Input geben: 42
'42'
>>> print(42)
42
```
### Funktionen kombinieren
```python
>>> int(str(2))
2
>>> str(int('2'))
'2'
```
### Neue Funktionen definieren
Mit `def` können neue Funktionen definiert werden
```python
def my_print_func(some_text):
print(some_text)
def my_add(a, b):
return a + b
my_print_func(my_add(1, 2)) # prints 3
```
---
## Imports
Mit `import` können Module (andere Python-Datein) importiert und benutzt werden
```python
import math
print(math.cos(math.pi)) # prints -1.0
```
Mit `from` und `import` können Sachen aus einem Modul spezifisch importiert werden
```python
from math import cos, pi
print(cos(pi)) # prints -1.0
```
---
## Scopes
Variabeln existieren in so genannten Scopes, am besten veranschaulicht man sich das einfach:
```python
GLOBAL_X = 42
def my_func():
x_in_func = 42 # x_in_func wird hier im Scope der Funktion erstellt
print(GLOBAL_X) # GLOBAL_X ist im globalen Scope,
# also auch hier im Funktions-Scope, weil dieser Scope auch im globalen Scope ist
print(x_in_func) # wirft einen Fehler, weil x_in_func nicht im Scope ist
print(GLOBAL_X) # Global Scope
```

View File

@ -0,0 +1,57 @@
# Korrektur Exercise-01
## Häufige Fehler
### Aufgabe 1.1
Wer weiterhin Probleme bei der Installation hat, bitte nach dem Tutorat
### Aufgabe 1.2
- Terminierung war nicht erfüllt für $x,y=0$ aber nicht $x = y$
- Dadurch auch kein Algorithmus laut Definition der Vorlesung, gab keinen Abzug wenn man alle Bedingungen als erfüllt ansah
### Aufgabe 1.3
- Es ging vor allem um den Unterschied zwischen der Python-Shell und dem normalen ausführen von `.py` Dateien
### Aufgabe 1.4
- Achtet auf die genau Anforderung!!!
```sh
Python
Python
Python
```
heißt nicht
```sh
Python
Python
Python
```
oder
```sh
Python
Python
Python
```
oder
```sh
Python
Python
Python
```
## Punkteverteilung
![image not found](./src/punkteverteilung.png)

View File

@ -0,0 +1,5 @@
# [Exercise-02](https://proglang.informatik.uni-freiburg.de/teaching/info1/2023/exercise/sheet02.pdf)
- Abgabe 30.10.2023 9:00 Uhr
- Achtet auf den Build-Output (Linter, Notes, ...)
- Fragen?

212
Tutorium/tut02/GIT.md Normal file
View File

@ -0,0 +1,212 @@
# Beispiel Git-Workflow
---
## SSH-Key generieren und im Git hinzufügen
### Linux & Mac-OS
Generiere einen Key mit
```sh
ssh-keygen -t ed25519 -C "you@mail.com"
```
Gib den Key in die Konsole aus mit
```sh
cat ~/.ssh/id_ed25519.pub
```
Kopiere mit Strg+Shift+C oder Rechtklick den Key aus dem Terminal und fügen ihn im [Git](https://git.laurel.informatik.uni-freiburg.de/user/settings/keys) als SSH Key hinzu.
### Windows
Generiere einen Key und kopiere ihn
```ps
ssh-keygen.exe -t ed25519 -C "you@mail.com"
cat ~/.ssh/id_ed25519.pub | clip
```
fügen dann den Key im [Git](https://git.laurel.informatik.uni-freiburg.de/user/settings/keys) als SSH Key hinzu.
### Mac
Generiere einen Key mit
```sh
ssh-keygen -t ed25519 -C "you@mail.com"
pbcopy < ~/.ssh/id_ed25519.pub
```
fügen dann den Key im [Git](https://git.laurel.informatik.uni-freiburg.de/user/settings/keys) als SSH Key hinzu.
---
## Das Repository clonen
Erstmal ist es wichtig wie man sich im Terminal überhaupt bewegt und umschaut. Wenn wir das Terminal starten, egal ob in Windows/Linux/Mac landen wir im Home-Verzeichnis often bezeichnet als `~`. Um den ersten Schritt zu gehen müssen wir erstmal wissen was wir hier überhaupt haben. Hierfür haben wir das Programm `ls`, welches den Inhalt in einem (ohne Argumente im aktuellen) Verzeichnis auflistet. Eine Beispielausgabe wäre:
```sh
nils@linux ~> ls
total 16
drwxr-xr-x 2 nils nils 4096 Oct 27 02:14 Desktop/
drwxr-xr-x 2 nils nils 4096 Oct 27 02:16 Downloads/
drwxr-xr-x 2 nils nils 4096 Oct 27 02:14 Pictures/
drwxr-xr-x 2 nils nils 4096 Oct 27 02:14 Videos/
```
Nun können wir uns in die anderen Verzeichnisse bewegen mit `cd` (change directory).
```sh
nils@linux ~> cd Downloads/
nils@linux ~/Downloads> ls
total 0
-rw-r--r-- 1 nils nils 0 Oct 27 02:19 cat.png
```
mit `cd ..` können wir uns jetzt ein Verzeichnis wieder nach oben bewegen
```sh
nils@linux ~/Downloads> cd ..
nils@linux ~> ls
total 16
drwxr-xr-x 2 nils nils 4096 Oct 27 02:14 Desktop/
drwxr-xr-x 2 nils nils 4096 Oct 27 02:19 Downloads/
drwxr-xr-x 2 nils nils 4096 Oct 27 02:14 Pictures/
drwxr-xr-x 2 nils nils 4096 Oct 27 02:14 Videos/
```
nun clonen wir das Repository indem wir ins [Git](https://git.laurel.informatik.uni-freiburg.de/2021WS-EiP/) gehen, auf unser persönliches Repository gehen. Und oben bei **SSH** auf **Copy**/**Kopieren** gehen.
Nun müssen wir einfach nur noch folgenden Befehl eingeben
```sh
nils@linux ~> git clone ssh://git@git.laurel.informatik.uni-freiburg.de:2222/2021WS-EiP/np163.git
Cloning into 'np163'...
The authenticity of host '[git.laurel.informatik.uni-freiburg.de]:2222 ([132.230.166.132]:2222)' can't be established.
ED25519 key fingerprint is SHA256:zR3d+3MewcoiAuwVidHYfWcsNjT/OVz5FR6IwIyTNCs.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[git.laurel.informatik.uni-freiburg.de]:2222' (ED25519) to the list of known hosts.
remote: Enumerating objects: 594, done.
remote: Counting objects: 100% (594/594), done.
remote: Compressing objects: 100% (573/573), done.
remote: Total 594 (delta 336), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (594/594), 86.90 KiB | 2.63 MiB/s, done.
Resolving deltas: 100% (336/336), done.
```
nun können wir mit `ls` nachschauen dass ein neuer Ordner erschienen ist, in meinem Fall **np163**.
```sh
nils@linux ~> ls
total 20
drwxr-xr-x 2 nils nils 4096 Oct 27 02:14 Desktop/
drwxr-xr-x 2 nils nils 4096 Oct 27 02:19 Downloads/
drwxr-xr-x 2 nils nils 4096 Oct 27 02:14 Pictures/
drwxr-xr-x 2 nils nils 4096 Oct 27 02:14 Videos/
drwxr-xr-x 17 nils nils 4096 Oct 27 02:24 np163/
```
Nun können wir diesen Ordner in VSCode öffnen und haben einen Workspace um die Übungsaufgaben zu bearbeiten.
---
Nun bewegen wir uns ins Git-Verzeichnis mit `cd np163`. Und führen unseren ersten Git-Command aus `git status`
```sh
nils@linux ~/np163 (master)> git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
```
wir sehen, dass aktuell noch nichts im Verzeichnis geändert wurde. Das ändern wir jetzt indem wir in VSCode eine `hello_world.py` erstellen. Und den `git status` wiederholen
```sh
nils@linux ~/np163 (master)> git status
On branch master
Your branch is up to date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
hello_world.py
nothing added to commit but untracked files present (use "git add" to track)
```
hier schlägt uns Git auch direkt schon vor `git add` zu verwenden um die neue Datei hinzuzufügen.
```sh
nils@linux ~/np163 (master)> git add hello_world.py
nils@linux ~/np163 (master)> git status
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: hello_world.py
```
mit `git add -A` können alle aktuelle Änderungen hinzugefügt werden.
nun können wir die Datei in unser Git eintragen indem wir `git commit -m 'meine nachricht'` verwenden.
```sh
nils@linux ~/np163 (master)> git commit -m 'created hello_world.py'
[master 4191d5b] created hello_world.py
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 hello_world.py
```
und diese Änderung dann mit `git push` hochladen.
```sh
nils@linux ~/np163 (master)> git push
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 16 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 285 bytes | 285.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: . Processing 1 references
remote: Processed 1 references in total
To ssh://git.laurel.informatik.uni-freiburg.de:2222/2021WS-EiP/np163.git
06b6eb7..4191d5b master -> master
```
---
## Git - VSCode
Zunächst erstellen wir eine Datei mit dem Namen `hello_world.py` über die Verzeichnisverwaltung von VSCode. Wir sehen dass die neue Datei bereits grün angezeigt, weil es eine neue Datei im Git ist.
![image not found](src/vscode-01.png)
Nun wechsel wir die Ansicht von der Verzeichnisverwaltung zu Git ganz links außen.
![image not found](src/vscode-02.png)
Nun drücken wir bei unserer neu erstellten Datei auf das `+`. Diese wird dann als `Staged Changes` angezeigt.
![image not found](src/vscode-03.png)
Nun legen wir eine Nachricht fest welche die Änderungen representiert und beschreibt.
![image not found](src/vscode-04.png)
Nun drücken wir auf `Commit` und nun sind unsere Änderungen übernommen.
![image not found](src/vscode-05.png)
Nun können wir noch auf `Sync Changes` drücken um die Änderungen auch an den Git-Services **Gitea** zu schicken. Danach werden keine weiteren Dateien mehr im Git-Reiter angezeigt und online sehen wir dass unsere Änderungen hochgeladen wurden.
![image not found](src/vscode-06.png)
![image not found](src/vscode-07.png)
---
Für Anregung gerne eine kurze [Mail](mailto:nils@narl.io) schreiben.

21
Tutorium/tut02/README.md Normal file
View File

@ -0,0 +1,21 @@
# Tutorium 02 - 27.10.2023
## Today
- [Korrektur Exercise-01](./CORRECTION.md)
- [Zusammenfassung Vorlesung](./COMPREHENSION.md)
- [Exercise-02](./EXERCISE-02.md)
- [Beispiel Git-Workflow](./GIT.md)
## About me
- [nils@narl.io](mailto:nils@narl.io)
- Discord: [.narl](https://discord.com/users/208979474988007425)
- Telegram: [@narl_np](https://t.me/narl_np)
- [Feedback](https://s.narl.io/s/Feedback-Tutorium-01)
<img src="../../src/img/mailto.png" height="200">
<img src="../../src/img/discord.png" height="200">
<img src="../../src/img/telegram.png" height="200">
<img src="../../src/img/feedback-google-forms.png" height="200">
<img src="./src/tutorium-02.png" height="200">

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -0,0 +1 @@
print("hello world")

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB