Hong-Phuc Bui
2024-05-15 9879363a9e020c6a3c390852a986adb8d9cf7284
Template 4 Students OK
2 files modified
3 files added
107 ■■■■■ changed files
funktion-modular/calendar/month_of_year.py 4 ●●●● patch | view | raw | blame | history
funktion-modular/study-effort/README.md 42 ●●●●● patch | view | raw | blame | history
funktion-modular/study-effort/Vorlesungen.txt 3 ●●●●● patch | view | raw | blame | history
funktion-modular/study-effort/effort_semester.py 53 ●●●●● patch | view | raw | blame | history
python-grundlage/dice-simulation.py 5 ●●●●● patch | view | raw | blame | history
funktion-modular/calendar/month_of_year.py
@@ -67,7 +67,7 @@
    diff = (7 + day_of_first_date - first_day_of_week) % 7
    # -> empty column
    for _ in range(diff, 0, -1):
        month_view += ("#"*(column_width - 1) + "-")
        month_view += ("-" + "#"*(column_width - 1) )
    # -> next days in the first week
    while day + diff <= 7:
        month_view += format_day(day, column_width)
@@ -97,5 +97,5 @@
if __name__ == "__main__":
    month = int(sys.argv[1])
    year = int(sys.argv[2])
    cal = build_calendar(month, year, 4)
    cal = build_calendar(month, year, 5)
    print(cal)
funktion-modular/study-effort/README.md
New file
@@ -0,0 +1,42 @@
# Study Effort
1. Erstellen Sie einen Ordner `study-effort` für das Projekt!
2. In der Ordner legen Sie die Datei `Vorlesungen.txt` mit folgenden Inhalt an:
```text
#Name; ECTS; Veranstaltung pro Woche
Programmierung 2; 5; 2
Mathematik 2; 5; 3
```
3. Schreiben Sie ein Python Programm `effort_semester.py`, das wie folgt genutzt wird:
```shell
$ python3 effort_semester.py Vorlesungen.txt
Vorlesung                  ECTS         V-Ü-T/Woche   Selbstudiumszeit pro Woche
Programmierung 2           5            2              <>
Mathematik 2               5            3              <>
--------------------------------------------------------------------------------
                                                       <>
```
Die Platzhalter `<>` sollen mit richtigen Werten ersetzt werden.
Sie können folgenden Funktionen benutzen:
* String Verarbeitung
    * `str.ljust()`
    * `str.rjust()`
* Datei-Handling
    * `open()`
Sie sollen das Programm nach Semantik in Funktionen aufteilen.
Ergänzen Sie die Datei `Vorlesungen.txt` mit weiteren Vorlesungen und testen Sie das Programm,
ob es noch korrekt funktioniert.
funktion-modular/study-effort/Vorlesungen.txt
New file
@@ -0,0 +1,3 @@
#Name; ECTS; Veranstaltung pro Woche
Programmierung 2; 5; 2
Mathematik 2; 5; 3
funktion-modular/study-effort/effort_semester.py
New file
@@ -0,0 +1,53 @@
#! /usr/bin/evn python
"""
Programm zum Berechnen den Aufwand für das Selbststudium pro Woche in einem Semester.
Das Semester hat 15 Woche.
Eine Doppelstunde (DS) entspricht 90 Minuten. Ein ECTS entspricht einen Aufwand von 30 Stunden.
Eine Veranstaltung (Vorlesung, Übung, Tutorium) ist 2 DS.
Die Vorlesungen in einem Semester werden in einer Text-Datei erfasst. Ein Template ist wie folgt:
```txt
#Name; ECTS; Veranstaltung pro Woche
Programmierung 2; 5; 2
Mathematik 2; 5; 3
```
Usage:
$python effort_semester.py Vorlesungen.txt
                 Vorlesung ECTS         V-Ü-T/Woche   Selbstudiumszeit pro Woche
          Programmierung 2 5            2              <>
              Mathematik 2 5            3              <>
--------------------------------------------------------------------------------
                                                       <>
"""
import sys
from typing import Final
SEMESTER_LENGTH: Final[int] = 15  # 15 Woche pro Semester
def collect_lectures_from_file(lecture_filename:str) -> list[tuple[str, float, float]]:
    # Your code here
    pass
def compute_semester_effort(lectures: list[tuple[str, float, float]]) -> list[tuple[str, float, float, float]]:
    # Your code here
    pass
def print_effort(effort: list[tuple[str, float, float, float]]) -> None:
    # Your code here
    pass
if __name__ == "__main__":
    lecture_filename = sys.argv[1]
    lectures = collect_lectures_from_file(lecture_filename)
    effort = compute_semester_effort(lectures)
    print_effort(effort)
python-grundlage/dice-simulation.py
@@ -1,8 +1,9 @@
#! /usr/bin/evn python
import random
from typing import Final
random.seed(5643)
experiments = 500
experiments: Final[int] = 500
dice_roll = tuple(random.randint(1, 6) for r in range(0, experiments))
absolute_frequency = tuple((face, len([f for f in dice_roll if f == face]))
                           for face in range(1, 6 + 1)
@@ -16,4 +17,4 @@
relative_frequency = tuple(
    (absolute_frequency[idx][0], absolute_frequency[idx][1] / experiments) for idx in range(1, 6 + 1)
)
)