Created
June 7, 2025 18:42
-
-
Save MajliTech/5d7009daba79ab52961b4afd22dc7fdf to your computer and use it in GitHub Desktop.
Kartkówka z szalonym zbysiem - podstawa
This file contains hidden or 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
from decimal import Decimal | |
from math import sqrt | |
print("Program oblicza obwód, pole i przekątną kwadratu") | |
a = input("Wpisz bok: ") | |
try: | |
a = Decimal(a) | |
if a.is_nan(): | |
raise Exception | |
if not a>0: | |
raise Exception | |
except: | |
while True: | |
print("Nie jestem w stanie pracować na podanych danych! Prosze je podać ponownie.") | |
a = input("Wpisz bok: ") | |
try: | |
a = Decimal(a) | |
if a.is_nan(): | |
raise Exception | |
if not a>0: | |
raise Exception | |
break | |
except: | |
continue | |
obw = a*4 | |
pole = a**2 | |
przekątna = a*Decimal(sqrt(2)) | |
print(f"Na podstawie danych można wyliczyć: Obwód: {obw}; Pole: {pole}; Przekątna: {przekątna}") |
This file contains hidden or 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
from decimal import Decimal | |
from math import sqrt | |
print("Program oblicza obwód, pole i przekątną prostokąta") | |
a = input("Wpisz bok A: ") | |
b = input("Wpisz bok B: ") | |
try: | |
a = Decimal(a) | |
b = Decimal(b) | |
if a.is_nan() or b.is_nan(): | |
raise Exception | |
if not a>0 or not b>0: | |
raise Exception | |
except: | |
while True: | |
print("Nie jestem w stanie pracować na podanych danych! Prosze je podać ponownie.") | |
a = input("Wpisz bok A: ") | |
b = input("Wpisz bok B: ") | |
try: | |
a = Decimal(a) | |
b = Decimal(b) | |
if a.is_nan() or b.is_nan(): | |
raise Exception | |
if not a>0 or not b>0: | |
print("ehll") | |
raise Exception | |
break | |
except: | |
continue | |
obw = a*2+b*2 | |
pole = a*b | |
przekątna = sqrt(a**2+b**2) | |
print(f"Na podstawie danych można wyliczyć: Obwód: {obw}; Pole: {pole}; Przekątna: {przekątna}") |
This file contains hidden or 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
from decimal import Decimal | |
from math import sqrt | |
print("Program oblicza obwód i pole trójkąta") | |
a = input("Wpisz bok A: ") | |
b = input("Wpisz bok B: ") | |
c = input("Wpisz bok C: ") | |
h = input("Wpisz wysokośc opuszczoną na bok A: ") | |
try: | |
a = Decimal(a) | |
b = Decimal(b) | |
c = Decimal(c) | |
h = Decimal(h) | |
if a.is_nan() or b.is_nan() or c.is_nan() or h.is_nan(): | |
raise Exception | |
if not a>0 or not b>0 or not c>0 or not h>0: | |
raise Exception | |
except: | |
while True: | |
print("Nie jestem w stanie pracować na podanych danych! Prosze je podać ponownie.") | |
a = input("Wpisz bok A: ") | |
b = input("Wpisz bok B: ") | |
c = input("Wpisz bok C: ") | |
h = input("Wpisz wysokośc opuszczoną na bok A: ") | |
try: | |
a = Decimal(a) | |
b = Decimal(b) | |
c = Decimal(c) | |
h = Decimal(h) | |
if a.is_nan() or b.is_nan() or c.is_nan() or d.is_nan(): | |
raise Exception | |
if not a>0 or not b>0 or not c>0 or not h>0: | |
raise Exception | |
break | |
except: | |
continue | |
obw = a+b+c | |
pole = (a*h)/2 | |
print(f"Na podstawie danych można wyliczyć: Obwód: {obw}; Pole: {pole}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment