Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr 16 #95

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added Volkov_KM-42.txt
Empty file.
38 changes: 38 additions & 0 deletions practice-16/pr16.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import math

def check(text):
while(True):
try:
num = float(input(text))
assert num > 0
except (ValueError, AssertionError):
print('This is not valid option.')
continue
else:
return num
break

def triangle_ineq(func):
def inner(*args, **kwargs):
while (True):
try:
a = check('Enter the first side: ')
b = check('Enter the second side: ')
c = check('Enter the third side: ')
assert a + b > c
assert a + c > b
assert b + c > a
except AssertionError:
print('This sides is not valid for triangle')
continue
else:
print(f'Area of a thiangle : {func(a, b, c)}')
break
return inner

@triangle_ineq
def area_calculation(a = None, b = None, c = None):
p = round((a + b + c) / 2, 2)
return round(math.sqrt(p * (p - a) * (p - b) * (p - c)), 2)

area_calculation()