-
Notifications
You must be signed in to change notification settings - Fork 1
/
gu-ito-5.py
43 lines (26 loc) · 907 Bytes
/
gu-ito-5.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
'''You are required to write a program that calculates and prints the area of a triangle given its base and height. Implement a class named 'Triangle' without any parameter in its constructor.
Input:
The input consists of two lines. Each line contains an integer representing either the base or the height of the triangle.
Output:
Output the area of the triangle.
Sample Input:
6
6
Sample Output:
18'''
class Triangle:
#..... YOUR CODE STARTS HERE .....
def calculate_area(self,b,h):
return 0.5*b*h
#..... YOUR CODE ENDS HERE .....
def main():
triangle = Triangle()
# Input for the base of the triangle
base = int(input())
# Input for the height of the triangle
height = int(input())
# Calculate and print the area of the triangle
area = triangle.calculate_area(base, height)
print(area)
if __name__ == "__main__":
main()