Created
September 10, 2024 08:30
-
-
Save BMU-Verlag/8ec576fcb37cf647249f56f08e63b86f to your computer and use it in GitHub Desktop.
taschenrechner in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def addiere(a, b): | |
return a + b | |
def subtrahiere(a, b): | |
return a - b | |
def multipliziere(a, b): | |
return a * b | |
def dividiere(a, b): | |
if b != 0: | |
return a / b | |
else: | |
return "Durch 0 teilen ist nicht erlaubt" | |
print("Wähle die Operation:") | |
print("1. Addition") | |
print("2. Subtraktion") | |
print("3. Multiplikation") | |
print("4. Division") | |
auswahl = input("Gib die Nummer der gewünschten Operation ein: ") | |
num1 = float(input("Erste Zahl: ")) | |
num2 = float(input("Zweite Zahl: ")) | |
if auswahl == '1': | |
print("Ergebnis:", addiere(num1, num2)) | |
elif auswahl == '2': | |
print("Ergebnis:", subtrahiere(num1, num2)) | |
elif auswahl == '3': | |
print("Ergebnis:", multipliziere(num1, num2)) | |
elif auswahl == '4': | |
print("Ergebnis:", dividiere(num1, num2)) | |
else: | |
print("Ungültige Eingabe") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment