Describe the TrianglePS(a, P, S) procedure that calculates on the side a of an equilateral triangle its perimeter P = 3·a and area S = a2**√3/4 (a – input, P and S — output parameters are all

parameters). Using this procedure, find the perimeters and areas of three equilateral triangles with these sides.How else can I write.Thank you in advance

“ `

```
import math
def proc(a):
P = 3 * a
S =a**2*sqrt*3/4
return [P, S]
x = [1, 2, 3]
for elem in x:
print(proc(elem)[0])
print(proc(elem)[1])
```

`

### >Solution :

Bear in mind that a Python function can return a tuple – i.e., effectively more than one value. Therefore this could be greatly simplified as follows:

```
import random
def TrianglePS(a):
return 3 * a, 3 ** 0.5 / 4 * a * a
for i in range(3):
a = random.randrange(1, 10)
print(f'a={a}')
p, s = TrianglePS(a)
print(f'P={p}')
print(f'S={s}')
```