Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python程序,用于打印矩形的面积和周长(如果显示用户类型1区域,则显示用户类型2周长)_Python - Fatal编程技术网

Python程序,用于打印矩形的面积和周长(如果显示用户类型1区域,则显示用户类型2周长)

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

查找矩形区域的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
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