"""
Learning Goals:
 - Use for loops when reading and writing algorithms to repeat actions a specified number of times
 - Recognize which numbers will be produced by a range expression
 - Translate algorithms from control flow charts to Python code
 - Use nesting of statements to create complex control flow
"""


result = 0
for i in range(5):
    result = result + i
print(result)

####

x = 0
for i in range(20):
    x = i - x
print(x)

###

for i in range(10, 0, -1):
    print(i)

####

s = ""
for i in range(10, 14):
    s = s + str(i) + "-"
print("My result:", s)

####

for x in range(1, 4):
    print("XXXX")
    for y in range(1, 5):
        print(x, y)

####

import tkinter as tk # shorten library name

def draw(canvas):
    for row in range(8):
        top = row * 50
        bottom = top + 50
        for col in range(8):
            left = col * 50
            right = left + 50
            if row % 2 == 0:
                color = "red"
            else:
                color = "green"

            canvas.create_rectangle(left, top, right, bottom, fill=color)

def makeCanvas(w, h):
    root = tk.Tk()
    canvas = tk.Canvas(root, width=w, height=h)
    canvas.configure(bd=0,
                     highlightthickness=0)
    canvas.pack()
    draw(canvas)
    root.mainloop()

makeCanvas(400, 400)