Python程序,用于打印矩形的面积和周长(如果显示用户类型1区域,则显示用户类型2周长)
查找矩形区域的Python程序 我是初学者,如果我按照要求使用开关盒,需要您的帮助,请参见图片Python程序,用于打印矩形的面积和周长(如果显示用户类型1区域,则显示用户类型2周长),python,Python,查找矩形区域的Python程序 我是初学者,如果我按照要求使用开关盒,需要您的帮助,请参见图片 width = float(input('Please Enter the Width of a Rectangle: ')) height = float(input('Please Enter the Height of a Rectangle: ')) # calculate the area Area = width * height # calculate the Perimeter P
width = float(input('Please Enter the Width of a Rectangle: '))
height = float(input('Please Enter the Height of a Rectangle: '))
# calculate the area
Area = width * height
# calculate the Perimeter
Perimeter = 2 * (width + height)
print("\n Area of a Rectangle is: %.2f" %Area)
print(" Perimeter of Rectangle is: %.2f" %Perimeter)
据我所知,Python没有开关盒。你可以用if-elif吗
width = float(input('Please Enter the Width of a Rectangle: '))
height = float(input('Please Enter the Height of a Rectangle: '))
# calculate the area
Area = width * height
# calculate the Perimeter
Perimeter = 2 * (width + height)
AreaOrPerimeter = int(input('1:Area / 2:Perimeter: '))
if AreaOrPerimeter == 1:
print("\n Area of a Rectangle is: %.2f" % Area)
elif AreaOrPerimeter == 2:
print(" Perimeter of Rectangle is: %.2f" % Perimeter)
else:
print("Invalid input")
非常感谢。我认为像这样的东西定义了字符串(参数):切换器={0:“零”,1:“一”,2:“二”,切换器={1:“面积”,2:“周长”,}我想每天从文档文件夹中的特定子行自动下载outlook附加文件&它应该通过winscp从文档文件夹复制到linux远程服务器a,文件将从服务器移动到/root中的服务器B