mirror of
https://github.com/JonasunderscoreJones/EPI-2324.git
synced 2025-10-23 16:39:21 +02:00
Added GPR ue03
This commit is contained in:
parent
3382a22a42
commit
69f6734b81
4 changed files with 53 additions and 1 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,5 @@
|
||||||
/EPR/ue00/7987847_epr-blatt00.zip
|
/EPR/ue00/7987847_epr-blatt00.zip
|
||||||
/EPR/ue01/7987847_epr-blatt01.zip
|
/EPR/ue01/7987847_epr-blatt01.zip
|
||||||
/EPR/ue02/7987847_epr-blatt02.zip
|
/EPR/ue02/7987847_epr-blatt02.zip
|
||||||
|
|
||||||
|
/GPR/ue03/gpr_blatt03_7987847_werner.zip
|
20
GPR/ue03/README.md.txt
Normal file
20
GPR/ue03/README.md.txt
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
author: 7987847, Werner
|
||||||
|
|
||||||
|
Aufgabe 1
|
||||||
|
---
|
||||||
|
|
||||||
|
Zur Nutzung muss eine kompatible Python version installiert sein.
|
||||||
|
Akzeptiert werden alle Python 3.x Versionen.
|
||||||
|
|
||||||
|
Das Programm kann mit dem Befehl `python3 main.py` im Ordner gestartet werden.
|
||||||
|
|
||||||
|
Nach dem Start wird der Benutzer aufgefordert, eine natürliche Zahl einzugeben.
|
||||||
|
Diese wird daraufhin in binär umgewandelt und ausgegeben.
|
||||||
|
|
||||||
|
Testfälle
|
||||||
|
---
|
||||||
|
Im Programmcode sind zu jeder der beiden Mittel jeweils 3 Testfälle angegeben.
|
||||||
|
|
||||||
|
PEP8
|
||||||
|
---
|
||||||
|
Der Programmcode ist soweit wie möglich nach PEP8 abgestimmt.
|
BIN
GPR/ue03/gpr_blatt03_7987847_werner.pdf
Normal file
BIN
GPR/ue03/gpr_blatt03_7987847_werner.pdf
Normal file
Binary file not shown.
30
GPR/ue03/main.py
Normal file
30
GPR/ue03/main.py
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
'''GPR Übungsblatt 03'''
|
||||||
|
__author__ = "7987847, Werner"
|
||||||
|
|
||||||
|
def dec_to_bin(zahl:int) -> str:
|
||||||
|
'''Umwandlung einer Dezimalzahl in eine Binärzahl
|
||||||
|
zahl: Dezimalzahl
|
||||||
|
'''
|
||||||
|
if zahl == 0:
|
||||||
|
return '0'
|
||||||
|
binzahl = ''
|
||||||
|
while zahl > 0:
|
||||||
|
binzahl = str(zahl % 2) + binzahl
|
||||||
|
zahl //= 2
|
||||||
|
return binzahl
|
||||||
|
|
||||||
|
|
||||||
|
print("Es wird eine Dezimalzahl in eine Binärzahl umgewandelt.")
|
||||||
|
print("Geben Sie eine Dezimalzahl ein.")
|
||||||
|
print(dec_to_bin(int(input("Dezimalzahl: "))))
|
||||||
|
|
||||||
|
# Testfälle
|
||||||
|
|
||||||
|
# dec_to_bin(0)
|
||||||
|
# Ausgabe: 0
|
||||||
|
|
||||||
|
# dec_to_bin(1)
|
||||||
|
# Ausgabe: 1
|
||||||
|
|
||||||
|
# dec_to_bin(69)
|
||||||
|
# Ausgabe: 1000101
|
Loading…
Add table
Add a link
Reference in a new issue