Razlaganje programa na manje dijelove - funkcije

Uvodni zadatak_1

Program

from math import *
print('Upiši koordinate točke A(x1,y1)')
x1 = int(input())
y1 = int(input())
print('Upiši koordinate točke B(x2,y2)')
x2 = int(input())
y2 = int(input())

print('Upiši koordinate točke C(x3,y3)')
x3 = int(input())
y3 = int(input())

print('Upiši koordinate točke D(x4,y4)')
x4 = int(input())
y4 = int(input())

a = sqrt(pow(x2-x1,2)+pow(y2-y1,2))
b = sqrt(pow(x3-x2,2)+pow(y3-y2,2))
c = sqrt(pow(x4-x3,2)+pow(y4-y3,2))
d = sqrt(pow(x4-x3,2)+pow(y4-y3,2))
e = sqrt(pow(x1-x3,2)+pow(y1-y3,2))

o1 = a + b + e  
s1 = o1/2
p1 = sqrt(s1*(s1-a)*(s1-b)*(s1-e))

o2 = c + d + e
s2 = o2/2
p2 = sqrt(s2*(s2-c)*(s2-d)*(s2-e))

p = p1 + p2
o = a + b + c + d

print('Povrsina zadanog četverokuta je',p,',a opseg',o)