底辺と高さから、角度と斜辺を計算するサンプル

  1. import math
  2. # 底辺
  3. bottom = 2
  4. # 高さ
  5. height = 1
  6. # 底辺と高さから角度を求める
  7. angle = math.atan(height / bottom) * 180 / math.pi
  8. # 底辺と高さから斜辺を求める
  9. hypotenuse = math.sqrt(math.pow(bottom, 2) + math.pow(height, 2))
  10. print(angle)
  11. print(hypotenuse)

戻る