1.5 KiB
1.5 KiB
title, timestamp, reason, tags, feature, thumbnail
| title | timestamp | reason | tags | feature | thumbnail | ||
|---|---|---|---|---|---|---|---|
| 07.11.2025 - Calendar | 07.11.2025 - 13:40 | Vorlesung 2 |
|
Templates/assets/logo.png | thumbnails/resized/e3f80df020cca3c2d7e2ffdc7d968e79_86cf658e.webp |
07.11.2025
Tasks
- Ablauf planen
- Beispiele planen
Ablauf
- Comments
# This is a Comment
"""This is a Docstring"""
'''This is also a Docstring'''
- Variablen
var = 5 # a Variable which holds the Number 5
- Print
- String
- f-String
'Single Quote String'
"Double Quote String"
txt = 'String'
f'This is a format-{txt}'
f"This is a format-{txt}"
- Datentypen
- Bool
- Int
- Float
flag = True | False
num = 1 | -1
price = 3.141 | -inf
- Rechenoperationen
- Addition
- Subtraktion
- Multiplication
- Exponentiation
- Division
- Ganzzahldivision
- Ringarithmetik
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
if 4 < 3:
print(True)
elif 5 < 4:
print("Hello")
else:
num = 7
- For/While - Loop
for i in range(0,10,2):
print(i)
i = 0
while i < 10:
print(i)
i += 2
- assert
assert num > 3 "Num must be greater than 3"
Beispiele
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")
