2018年1月8日 星期一

Python: Accept the base and height of a triangle and compute the area

Python: Accept the base and height of a triangle and compute the area

Python Basic: Exercise-30 with Solution

Write a Python program that will accept the base and height of a triangle and compute the area.
Python: Area of a triangle
A triangle is a polygon with three edges and three vertices. It is one of the basic shapes in geometry. A triangle with vertices A, B, and C is denoted triangle ABC.
  • Vertex of a triangle: The point at which two sides of a triangle meet.
  • Altitude of a triangle: The perpendicular segment from a vertex of a triangle to the line containing the opposite side.
  • Base of a triangle: The side of a triangle to which an altitude is drawn.
  • Height of a triangle: The length of an altitude.
Python: Area of a triangle
Sample Solution:-
b = int(input("Input the base : "))
h = int(input("Input the height : "))

area = b*h/2

print("area = ", area)

========== RESTART: F:/Python_APSC/py-ex-basic-30.py ===========
Input the base : 12
Input the height : 6
area =  36.0
>>> 

沒有留言:

張貼留言

RFID TI 培訓影片系列

RFID TI 培訓影片系列  https://www.ti.com/zh-tw/video/series/rfid.html 培訓影片系列 RFID 隨著創新技術日益發展,RFID 和 RF 術語越來越容易讓人混淆。本訓練系列詳細介紹了使用案例、權衡技術優缺點,讓您清楚知道該選...