我很难启动while循环,试图生成一个程序,该程序将根据用户输入的数字生成饼图或条形图。如何编写while循环以使其不会永远循环?我知道我可以对有限序列使用for循环,但我在这方面没有太多经验。任何指导都会有帮助的!在
从SimpleGraphics导入*
打印(“图表菜单:1.饼图,2.条形图”)
chart=int(输入(“为饼图输入1或为条形图输入2:”)
如果图表==1:title = input("Enter the title of the chart: ")
numSec = int(input("Enter the number of sectors: "))
tSum = int(input("Enter the total sum of all sector values: "))
gsize = int(input("Ehter the grid size (Between 10 and 400): "))
yLabel = input("Enter the label for the Y-Axis:")
while循环
-每个部门的名称
每个部门的价值
-绘制饼图
如果图表==2:
^{pr2}$
while循环
-每个类别的名称
-该类别的值
-绘制条形图