-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunits1.py
More file actions
31 lines (19 loc) · 834 Bytes
/
units1.py
File metadata and controls
31 lines (19 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
Einfaches Skript zur Umrechnung von Einheiten.
Um die benötigte Bibliothek "pint" [1] zu installieren, bitte das folgende
Kommando ausführen:
pip install pint
[1] https://pint.readthedocs.io/en/latest/
"""
import pint
einheiten = pint.UnitRegistry()
Q_ = einheiten.Quantity
max_geschwindigkeit = 130 * einheiten.kilometers / einheiten.hours
distance = einheiten.parse_expression(input('Bitte Entfernung eingeben: '))
print('Eingegebene Entfernung: {}'.format(distance))
time = einheiten.parse_expression(input('Bitte Zeit eingeben: '))
print('Eingegebene Zeit: {}'.format(time))
speed = distance / time
print('Geschwindigkeit: {}'.format(speed))
print('Geschwindigkeit in m/s: {}'.format(speed.to(einheiten.meter / einheiten.second)))
print('Geschwindigkeit in Basiseinheiten: {}'.format(speed.to_base_units()))