106 lines
1.5 KiB
Markdown
106 lines
1.5 KiB
Markdown
---
|
|
title: 07.11.2025 - Calendar
|
|
timestamp: 07.11.2025 - 13:40
|
|
reason: Vorlesung 2
|
|
tags:
|
|
- Calendar
|
|
- Vorlesung
|
|
feature: Templates/assets/logo.png
|
|
thumbnail: thumbnails/resized/e3f80df020cca3c2d7e2ffdc7d968e79_86cf658e.webp
|
|
---
|
|

|
|
# 07.11.2025
|
|
|
|
# Tasks
|
|
- [ ] Ablauf planen
|
|
- [ ] Beispiele planen
|
|
|
|
## Ablauf
|
|
- Comments
|
|
```python
|
|
# This is a Comment
|
|
|
|
"""This is a Docstring"""
|
|
'''This is also a Docstring'''
|
|
```
|
|
- Variablen
|
|
```python
|
|
var = 5 # a Variable which holds the Number 5
|
|
```
|
|
- Print
|
|
- String
|
|
- f-String
|
|
```python
|
|
'Single Quote String'
|
|
"Double Quote String"
|
|
|
|
txt = 'String'
|
|
f'This is a format-{txt}'
|
|
f"This is a format-{txt}"
|
|
```
|
|
- Datentypen
|
|
- Bool
|
|
- Int
|
|
- Float
|
|
```python
|
|
flag = True | False
|
|
num = 1 | -1
|
|
price = 3.141 | -inf
|
|
```
|
|
- Rechenoperationen
|
|
- Addition
|
|
- Subtraktion
|
|
- Multiplication
|
|
- Exponentiation
|
|
- Division
|
|
- Ganzzahldivision
|
|
- Ringarithmetik
|
|
```python
|
|
5 + 4 = 9
|
|
5.0 + 4 = 9.0
|
|
0.25 - 1 = -0.75
|
|
2*2 = 4
|
|
2**24 = 16.777.216
|
|
10 / 3 = 3.33
|
|
10 % 3 = 1
|
|
10 // 3 = 3
|
|
```
|
|
- If/Else
|
|
```python
|
|
if 4 < 3:
|
|
print(True)
|
|
elif 5 < 4:
|
|
print("Hello")
|
|
else:
|
|
num = 7
|
|
```
|
|
- For/While - Loop
|
|
```python
|
|
for i in range(0,10,2):
|
|
print(i)
|
|
|
|
i = 0
|
|
while i < 10:
|
|
print(i)
|
|
i += 2
|
|
```
|
|
- assert
|
|
```python
|
|
assert num > 3 "Num must be greater than 3"
|
|
```
|
|
|
|
## Beispiele
|
|
```python
|
|
import sys
|
|
def fn():
|
|
sys.stdout.flush()
|
|
return sys.stdin.readline()
|
|
|
|
num = {0: fn, 1: fn}[int(bool(sys.stdout.write("Enter a number: ")))]()
|
|
|
|
for print in {sys.stdout.write}:
|
|
print(f"Your number is: {num}\n")
|
|
```
|
|
|
|
---
|