Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 台形の面積コマンドライン入力から求める
# 上辺とか下辺が同じであればメッセージを変更する
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