New file |
| | |
| | | def calculate_luhn(number: int) -> int: |
| | | """ |
| | | calculate the Luhn-Checksum of a given number |
| | | :param number: |
| | | :return: |
| | | """ |
| | | checksum = 0 |
| | | while number != 0: |
| | | (quote, even) = divmod(number, 10) |
| | | (number, odd) = divmod(quote, 10) |
| | | print(f"odd = {odd} even = {even} ", end="") |
| | | checksum += even |
| | | odd = (odd*2) |
| | | if odd > 9: |
| | | odd = odd - 9 |
| | | print(f"twice_odd = {odd}, ", end="") |
| | | checksum += odd |
| | | print(f"sum = {checksum}") |
| | | print(checksum) |
| | | return checksum % 10 |
| | | |
| | | valide = [ |
| | | 3_78_28_22_46_31_00_05, 3_71_44_96_35_39_84_31, |
| | | 60_11_11_11_11_11_11_17, 5105105105105100 |
| | | ] |
| | | |
| | | cs = calculate_luhn(valide[1]) |
| | | print(cs) |
| | | |
New file |
| | |
| | | # Messfrequenz: Minuten |
| | | # Temperatur in Celcius |
| | | # Werten in einer Datei sind innerhalb von einem Tag |
| | | # Trennzeichen für Spalten ; |
| | | # Trennzeichen für Dezimal-Anteil . |
| | | |
| | | |
| | | 00:00 ; 15.6 |
| | | 00:01 ; 15.8 |
| | | 0:3 ; -9.0 |
| | | 0:4 ; ? |
| | | |
New file |
| | |
| | | # Eine Zeile in ein Tupel |
| | | # Uhrzeit wird in Anzahl der Minuten ab 0 Uhr konvertiert |
| | | # Temperatur wird in float konvertiert |
| | | |
| | | from typing import Final |
| | | |
| | | COLUMN_SEP : Final[str] = ";" |
| | | |
| | | def parser_time(time:str) -> int: |
| | | return 8 |
| | | |
| | | def parser_temperatur(temperatur: str) -> float: |
| | | return -2.6 |
| | | |
| | | |
| | | def parser_line(line: str) -> tuple[int, float]: |
| | | parts = line.split(COLUMN_SEP) |
| | | parts = [p.strip() for p in parts] |
| | | time, temp = |
New file |
| | |
| | | """ |
| | | |
| | | python timeinterval 8:20 10:30 |
| | | |
| | | |
| | | """ |
| | | |
| | | def zeit_in_minute(zeit: str) -> int: |
| | | (h,m) = zeit.split(":") |
| | | h = int(h) |
| | | m = h*60 + (int(m)) |
| | | return m |
| | | |
| | | |
| | | def zeit_differenz(start, end): |
| | | return abs(start - end) |
| | | |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | # eingabe entgegen nehmen |
| | | start_zeit = input("startzeit") |
| | | ende_zeit = input("endzeit") |
| | | start_minuten = zeit_in_minute(start_zeit) |
| | | end_minute = zeit_in_minute(ende_zeit) |
| | | diff = zeit_differenz(start_minuten, end_minute) |
| | | print(diff) |
| | | |
New file |
| | |
| | | import unittest |
| | | import time_interval as ti |
| | | |
| | | class TimeIntervalTestCase(unittest.TestCase): |
| | | def test_zeit_in_minute(self): |
| | | uhrzeit = "8:00" |
| | | time_from_zero = ti.zeit_in_minute(uhrzeit) |
| | | expected = 8*60 |
| | | self.assertEqual(time_from_zero, expected) |
| | | |
| | | def test_zeit_in_minute_2(self): |
| | | uhrzeit = "8:13" |
| | | time_from_zero = ti.zeit_in_minute(uhrzeit) |
| | | expected = 8 * 60 + 13 |
| | | self.assertEqual(time_from_zero, expected) |
| | | |
| | | def test_zeit_difference(self): |
| | | s = 6*60 + 30 |
| | | e = 14*60 + 15 |
| | | d = ti.zeit_differenz(s, e) |
| | | expected = 7*60 + 45 |
| | | self.assertEqual(d, expected) |
| | | |
| | | |
| | | if __name__ == '__main__': |
| | | unittest.main() |
New file |
| | |
| | | """ |
| | | |
| | | python main.py 8:00 10:10 |
| | | 130 |
| | | """ |
| | | |
| | | import sys |
| | | from time_interval import to_minute, print_diff |
| | | |
| | | start_time = sys.argv[1] |
| | | end_time = sys.argv[2] |
| | | |
| | | start_minute = to_minute(start_time) |
| | | end_minute = to_minute(end_time) |
| | | diff = end_minute - start_minute |
| | | |
| | | message = print_diff(start_time, end_time, diff) |
| | | print(message) |
| | | |
| | | |
New file |
| | |
| | | #! /usr/bin/env python |
| | | |
| | | |
| | | """ |
| | | |
| | | """ |
| | | |
| | | def to_minute(time: str) -> int: |
| | | t = time.split(":") |
| | | if len(t) == 1: |
| | | return int(t[0])*60 |
| | | return int(t[0])*60 + int(t[1]) |
| | | |
| | | |
| | | def to_time(diff: int) -> tuple[int, int]: |
| | | return divmod(diff, 60) |
| | | |
| | | |
| | | def print_diff(start_time, end_time, diff) -> str: |
| | | h,m = to_time(diff) |
| | | if h == 1: |
| | | stunde = "1 Stunde" |
| | | else: |
| | | stunde = f"{h} Stunden" |
| | | if m == 1: |
| | | minute = "1 Minute" |
| | | else: |
| | | minute = f"{m} Minuten" |
| | | return f"Zwischen {start_time} und {end_time} sind {stunde} und {minute} vergangen." |
| | | |
| | | |
| | | # Zwischen 8:00 und 9:20 sind 1 Stunde und 20 Minuten vergangen. |
New file |
| | |
| | | import unittest |
| | | from time_interval import to_minute |
| | | |
| | | class TimeIntervalTestCase(unittest.TestCase): |
| | | def test_to_minute(self): |
| | | time = "9:20" |
| | | minutes = to_minute(time) |
| | | expected = 9*60 + 20 |
| | | self.assertEqual(minutes, expected) |
| | | |
| | | def test_to_minute2(self): |
| | | time = "9" |
| | | minutes = to_minute(time) |
| | | expected = 9*60 |
| | | self.assertEqual(minutes, expected) |
| | | |
| | | |
| | | if __name__ == '__main__': |
| | | unittest.main() |
New file |
| | |
| | | # Demo Structure |
| | | |
| | | Wie viel Zeitaufwand muss ich für mein Studium investieren? |
| | | |
| | | |
| | | ## Beschreibung |
| | | .... |
| | | |
| | | ## Referenz |
| | | |
| | | |
| | | |
| | | |
| | | |
New file |
| | |
| | | [build-system] |
| | | requires = ["setuptools"] |
| | | build-backend = "setuptools.build_meta" |
| | | |
| | | [project] |
| | | name = "study-effort" |
| | | version = "0.0.1" |
| | | |
| | | [tool.setuptools.packages.find] |
| | | # All the following settings are optional: |
| | | where = ["src"] |
| | | |
| | | |
| | | |
| | | [project.scripts] |
| | | mystudy = "mystudy.main:main" |
| | | |
New file |
| | |
| | | from typing import Final |
| | | |
| | | lecture_time: Final[int] = 15 |
| | | ects_effort: Final[int] = 30 |
| | | |
| | | |
| | | def lecture_effort(lecture_pre_week, ects): |
| | | """ |
| | | :param lecture_pre_week: wie viel Veranstaltungen hat eine Vorlesung in der Woche |
| | | :param ects: Anzahl der ECTS der Vorlesung |
| | | :return: |
| | | """ |
| | | effort_in_time = ects * ects_effort |
| | | effort_per_week = effort_in_time / lecture_time # how many hours for a week |
| | | return effort_per_week - (lecture_pre_week * 1.5) |
| | | |
| | | |
| | | def format_lecture_effort(name, lecture_count, ects, effort): |
| | | return f"Für die Vorlesung {name} mit {ects} ECTS und {lecture_count} Veranstaltung pro Woche brauchen Sie {effort} Stunden zu lernen." |
| | | |
| | | |
| | | |
New file |
| | |
| | | import lecture |
| | | |
| | | lecture_count = input("Geben Sie die Anzahl der Veranstaltungen ein!") |
| | | lecture_per_week = int(lecture_count) |
| | | |
| | | ects_input = input("Geben Sie die ECTS-Zahl der Vorlesung ein!") |
| | | ects = int(ects_input) |
| | | |
| | | effort = lecture.lecture_effort(lecture_per_week, ects) |
| | | text = lecture.format_lecture_effort("Mathematik", lecture_per_week, ects, effort) |
| | | |
| | | print(text) |
New file |
| | |
| | | import unittest |
| | | import lecture |
| | | |
| | | class MyTestCase(unittest.TestCase): |
| | | def test_something(self): |
| | | ects_python = 2 |
| | | lecture_per_week = 2 |
| | | effort_per_week = lecture.lecture_effort(lecture_per_week, ects_python) |
| | | self.assertEqual(effort_per_week, 1.0) # add assertion here |
| | | |
| | | def test_format(self): |
| | | ects = 3 |
| | | lecture_per_week = 2 |
| | | name = "Informatik" |
| | | text = lecture.format_lecture_effort(name, lecture_per_week, ects, 8) |
| | | self.assertTrue(text.index(f"{ects}") >= 0) |
| | | self.assertTrue(text.index(name) >= 0) |
| | | self.assertTrue(text.index("8")) |
| | | |
| | | |
| | | if __name__ == '__main__': |
| | | unittest.main() |
New file |
| | |
| | | import turtle as t |
| | | |
| | | alpha = 12 |
| | | beta = 2*alpha |
| | | gamma = 180 - beta |
| | | |
| | | steps = 100 |
| | | petals = 5 |
| | | |
| | | init_angle = 5 |
| | | |
| | | for i in range(0, petals): |
| | | start_angle = init_angle + (i * 360 / petals) |
| | | t.setheading(start_angle) |
| | | t.left(alpha) |
| | | t.fd(steps) |
| | | t.right(beta) |
| | | t.fd(steps) |
| | | t.right(gamma) |
| | | t.fd(steps) |
| | | t.right(beta) |
| | | t.fd(steps) |
| | | |
| | | t.done() |
New file |
| | |
| | | import turtle as t |
| | | |
| | | steps = 200 |
| | | corner = 7 |
| | | alpha = 360 / corner |
| | | |
| | | |
| | | for i in range(0, corner): |
| | | t.fd(steps) |
| | | t.left(alpha) |
| | | |
| | | |
| | | t.done() |
| | | |