

Lg, Kristally
Code: Alles auswählen
#Kreisberechung
#Imports
import time
import sys
import os
#Variablen initalisieren
x = 1
Pi = 3.14159265359
y = 1
yy = 1
yyy = 1
#Einleitung
print("Kreisberechnung")
print("")
time.sleep(2)
#Auswahl treffen
while x == 1:
os.system('cls')
print("Zuerst müssen sie auswählen, welche Angabe vorhanden ist.")
time.sleep(2)
print("")
print("-----------------------------------------------------")
print("Wenn der Umfang vorhanden ist, tippen sie die 1 ein.")
print("Wenn der Radius vorhanden ist, tippen sie die 2 ein.")
print("Wenn Durchmesser vorhanden ist, tippen sie die 3 ein.")
print("-----------------------------------------------------")
time.sleep(1)
z = input("Welche Nummer wählen sie?: ")
#Unwandlung
try:
zahl = int(z)
except:
print(z + " war keine der angegebenen Möglichkeiten.")
time.sleep(1.5)
os.system('cls')
continue
#Wenn Umfang vorhanden
if zahl == 1:
x = 0
os.system('cls')
print("Der Umfang ist also vorhanden.")
print("")
time.sleep(0.5)
while yyy == 1:
u1 = input("Geben sie nun den Umfang ein: ")
try:
uFloat = float(u1)
except:
print(u1 + " ist keine gültige Zahl.")
continue
yyy = 0
#Rechnung
Durchmesser = uFloat/Pi
Radius = Durchmesser/2
Umfang = uFloat
#Wenn Radius vorhanden
if zahl == 2:
x = 0
os.system('cls')
print("Der Radius ist also vorhanden.")
print("")
time.sleep(0.5)
while y == 1:
r1 = input("Geben sie nun den Radius ein: ")
try:
rFloat = float(r1)
except:
print(r1 + " ist keine gültige Zahl.")
continue
y = 0
#Rechnung
Durchmesser = rFloat*2
Umfang = Pi*Durchmesser
Radius = rFloat
#Wenn Durchmesser vorhanden.
if zahl == 3:
x = 0
os.system('cls')
print("Der Durchmesser ist also vorhanden.")
print("")
time.sleep(0.5)
while yy == 1:
d1 = input("Geben sie nun den Durchmesser ein: ")
try:
dFloat = float(d1)
except:
print(d1 + " ist keine gültige Zahl.")
continue
yy = 0
#Rechnung
Umfang = Pi*dFloat
Radius = dFloat/2
Durchmesser = dFloat
#Ergebnis
os.system('cls')
print("--------------------------------------------")
print("Ihre Daten werden bearbeitet...")
print("--------------------------------------------")
time.sleep(1.5)
os.system('cls')
print("Ihre Daten lauten: ")
print("")
time.sleep(0.7)
print("Umfang: ", Umfang)
time.sleep(0.5)
print("Radius: ", Radius)
time.sleep(0.5)
print("Durchmesser: ", Durchmesser)
print("")
time.sleep(2)
#Frage nach restart
print("Wollen sie zurück zum Hauptmenü?")
print("Wenn Ja, tippen sie Ja, ein. Wenn nicht drücken sie eine beliebige Taste.")
Restart = (str(input()))
if Restart == "Ja":
x = 1
else:
print("")