0
我在開始一個while循環試圖生成一個程序,將產生從數字的餅圖或條形圖用戶將輸入的困難。 while循環如何編寫,因此它不會永遠循環?我知道我可以使用for循環來獲得有限的序列,但是我並沒有太多經驗。任何指導都會有幫助!繪圖的Python餅圖/條形圖使用while循環
從SimpleGraphics進口*
打印( 「圖表菜單:1.Pie圖表,圖表2.Bar」)
圖表= 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循環
-t他每個部門的名字
-the值各部門
-draw餅圖
如果圖表== 2:
title = input("Enter the title of the chart: ")
numCat = int(input("Enter the number of categories: "))
grid = int(input("Ehter the grid size (Between 10 and 400): "))
while循環
每個類別的-name
- 值對這一類
-draw條形圖
請添加一個縮進你的代碼才能正常格式化。 –