我如何将这个for循环变成流程图?

时间:2015-01-08 20:18:00

标签: python loops for-loop flowchart

 def buttons(self):
        labels = [
    '7','8','9','C',
    '4','5','6',' ',
    '1','2','3','-',  
    'esc','0','=','+', ]

    x = 1
    y = 0
    for label in labels:
        labelling = partial(self.calculate, label)
        tk.Button(self, text=label, width=3, relief='raised', bg="#87ceeb",
            command=labelling).grid(column=y, row=x)
        y += 1
        if y > 3:
            y = 0
            x += 1
    self.entry = tk.Entry(self, width=19, bg="#afeeee")
    self.entry.grid(row=0, column=0, columnspan=4)

嗨,我如何将此功能转换为流程图,包括for循环和if循环? (整个功能)感谢阅读

1 个答案:

答案 0 :(得分:0)

Set x=1, y=0
  |
 \|/
Create button at x,y
 /|\      |
  |      \|/
  |      increment y
  |         |
  |        \|/
  |       is y>3  ---yes ---> set y=0, increment x
  |          |                   |
  |          no                  |
  |         \|/                 \|/
  \---yes---are there more labels to make?
                 |
                 no
                 |
                \|/
               done

原谅糟糕的ASCII艺术