-
Notifications
You must be signed in to change notification settings - Fork 5
/
Ex_Sheet_1_Num_3.py
55 lines (38 loc) · 1.19 KB
/
Ex_Sheet_1_Num_3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""
Author: Gabriele Pompa
Identification Number: ABCXYZ [substitute with your Unisi Identification Number]
Date: 15-Mar-2020
File name: Ex_Sheet_1_Num_3.py
Description: This script calculates the area of a triangle, given its base and height.
"""
def triangleArea(b,h):
"""
Function triangleArea(b,h) calculates and returns the area of a triangle
of base 'b' and height 'h' in input.
Parameters:
b (float): base of the triangle.
h (float): height of the triangle.
Returns:
A (float): area of the circle.
"""
A = 0.5 * b * h
return A
def main():
"""
Function main() defines two baraibles base and heigth and computes the area
of a triangle that base and height.
Parameters:
None
Returns:
None
"""
# base and height of the triangle. Choosing base = 1.0 and height = 2.0
# we can test that the area is 1.0
base = 1.0
height = 2.0
# area of the triangle
area = triangleArea(base, height)
# Print section
print("Base = {}, Height = {} - Area of the triangle = {}".format(base, height, area))
if __name__ == "__main__":
main()