You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.2 KiB

print("Vitejte v kalulačce pro obdelník")
while True: ## celá kalkulačka ve while
while True:
try:
vstup_a = input("zadej Delku strany A (v cm):")
strana_a = float(vstup_a)
if strana_a > 0:
break
else:
print("chyba: Strana musi být kladna")
except:
print("chyba: nezadal si číslo")
while True:
try:
vstup_b = input("zadej Delku strany B (v cm):")
strana_b = float(vstup_b)
if strana_b > 0:
break
else:
print("chyba: Strana musi být kladna")
except:
print("chyba: musís zadat kladne cislo")
obvod = 2 * (strana_a+strana_b)
obsah = strana_a*strana_b
print("----Vysledky----")
print(f"Obdelnik se stranami {strana_a} cm a {strana_b} cm ma:")
print(f"Obvod: {obvod} cm")
print(f"Obsah: {obsah} cm")
print("Chcete další výpočet? ano/ne")
vstup_konec = input("ano/ne/a/n:")
if vstup_konec == "ne" or vstup_konec == "n":
break
else:
print("Jdeme na další výpočet.")
print("děkujeme za využiti naší kalkulačky")