"""
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(11):
    result = result + i
print(result)

###

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

###

for i in range(10):
    print(i)
    i = i + 2

###

for i in range(3, 8):
    print(i)

###

for i in range(2, 11, 2):
    print(i)

###

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

###

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

###

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

###

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

###

import tkinter as tk # shorten library name

def drawGrid(canvas, size):
    for row in range(size):
        top = row * 50
        bottom = top + 50
        if row % 2 == 0:
            color = "cyan"
        else:
            color = "red"
        for col in range(size):
            left = col * 50
            right = left + 50
            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()
    drawGrid(canvas, 7)
    root.mainloop()

makeCanvas(400, 400)
