Skip to content

Instantly share code, notes, and snippets.

@doraiso
Last active June 9, 2017 06:29
Show Gist options
  • Save doraiso/4689858df91b1b75e125a750e3a01478 to your computer and use it in GitHub Desktop.
Save doraiso/4689858df91b1b75e125a750e3a01478 to your computer and use it in GitHub Desktop.
# 台形の面積コマンドライン入力から求める
# 上辺とか下辺が同じであればメッセージを変更する
DAIKEI = "台形"
HEIHOU = "平方四辺形"
a = float(input("上辺? "))
b = float(input("下辺? "))
h = float(input("高さ? "))
daikei = (a + b) * h / 2
if a == b:
str = HEIHOU
print("それ平行四辺形じゃね?")
else:
str = DAIKEI
# 結果を表示
print(str,"の面積は", daikei, "cm2")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment