forked from phga/notes
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 57fc0d8fa4 | |||
|
|
2399cf6c6a | ||
| 6e8a5c119c | |||
|
|
602de0dbae |
1
read_this.org
Normal file
1
read_this.org
Normal file
@@ -0,0 +1 @@
|
|||||||
|
- [[https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/][Blog post about async]]
|
||||||
67
wi_20_21_gh1_ae.py
Executable file
67
wi_20_21_gh1_ae.py
Executable file
@@ -0,0 +1,67 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# Author: phga
|
||||||
|
# Date: 2021-10-28
|
||||||
|
# Description: Example code that enables implementation of possible solutions
|
||||||
|
# for a question from the final exam written by Computer Engineers
|
||||||
|
# THIS FILE CONTAINS ONE POSSIBLE SOLUTION
|
||||||
|
|
||||||
|
# KLAUSUR: WI_20_21_GH1_AE
|
||||||
|
from random import randint, seed
|
||||||
|
|
||||||
|
################ NICHT RELEVANT UM AUFGABE ZU BEARBEITEN
|
||||||
|
# seed(1)
|
||||||
|
# seed(2)
|
||||||
|
# Wen es interessiert: Das hier nennt sich list comprehension
|
||||||
|
zeiterfassungstabelle = [[tag, randint(6, 10) * i, randint(1, 30) * i - 1]
|
||||||
|
for i in [1, 2]
|
||||||
|
for tag in range(1, 32) if randint(0, 3)]
|
||||||
|
# Zeitentabelle noch nach Tagen sortieren
|
||||||
|
zeiterfassungstabelle = sorted(zeiterfassungstabelle, key=lambda row: row[0])
|
||||||
|
|
||||||
|
################ Hilfsfunktionen
|
||||||
|
|
||||||
|
def tageImMonat(monat, jahr):
|
||||||
|
return 31 # lel
|
||||||
|
|
||||||
|
|
||||||
|
def schreibeKopf(persnr, jahr, monat):
|
||||||
|
monat = ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli",
|
||||||
|
"August", "September", "Oktober", "November", "Dezember"][monat - 1]
|
||||||
|
heading = f'Mitarbeiter: {persnr: <5}{" "*8}{monat} {jahr}'
|
||||||
|
tbl_heading = f'Tag Kommen Gehen Anwesenheit Bemerkung{" "*6}'
|
||||||
|
tbl_spacer = "="*len(tbl_heading)
|
||||||
|
print("\n" + heading)
|
||||||
|
print(tbl_heading)
|
||||||
|
print(tbl_spacer)
|
||||||
|
|
||||||
|
|
||||||
|
def schreibeZeile(tag, std1, min1, std2, min2, anwTag, bemerkung):
|
||||||
|
anwStd = anwTag // 60
|
||||||
|
anwMin = anwTag % 60
|
||||||
|
if std1 == -1 and min1 == -1:
|
||||||
|
sm1 = " " * 5
|
||||||
|
anwT = "00:00"
|
||||||
|
else:
|
||||||
|
sm1 = f'{std1:02}:{min1:02}'
|
||||||
|
anwT = f'{anwStd:02}:{anwMin:02}'
|
||||||
|
|
||||||
|
if std2 == -1 and min2 == -1:
|
||||||
|
sm2 = " " * 5
|
||||||
|
anwT = "00:00"
|
||||||
|
else:
|
||||||
|
sm2 = f'{std2:02}:{min2:02}'
|
||||||
|
anwT = f'{anwStd:02}:{anwMin:02}'
|
||||||
|
|
||||||
|
tbl_row = f'{tag: <5}{sm1} {sm2} {anwT}{" "*8}{bemerkung}'
|
||||||
|
print(tbl_row)
|
||||||
|
|
||||||
|
|
||||||
|
def schreibeFuss(anwMonat):
|
||||||
|
anwStd = anwMonat // 60
|
||||||
|
anwMin = anwMonat % 60
|
||||||
|
tbl_spacer = "="*48
|
||||||
|
footer = f'Summe Anwesenheit: {anwStd:02}:{anwMin:02}'
|
||||||
|
print(tbl_spacer)
|
||||||
|
print(footer + "\n")
|
||||||
|
|
||||||
|
################ LÖSUNGSANSATZ HIER BEGINNEN
|
||||||
Reference in New Issue
Block a user