加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
calc_area.py 727 Bytes
一键复制 编辑 原始数据 按行查看 历史
Prajakta Sathe 提交于 2020-10-06 14:59 . Adding calc_area.py program
# Author: PrajaktaSathe
# Program to calculate the area of - square, rectangle, circle, and triangle -
shape = int(input("Enter 1 for square, 2 for rectangle, 3 for circle, or 4 for triangle: "))
if shape == 1:
side = float(input("Enter length of side: "))
print("Area of square = " + str(side**2))
elif shape == 2:
l = float(input("Enter length: "))
b = float(input("Enter breadth: "))
print("Area of rectangle = " + str(l*b))
elif shape == 3:
r = float(input("Enter radius: "))
print("Area of circle = " + str(3.14*r*r))
elif shape == 4:
base = float(input("Enter base: "))
h = float(input("Enter height: "))
print("Area of rectangle = " + str(0.5*base*h))
else:
print("You have selected wrong choice.")
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化