#
# Python Datei enthält Code-Stücke und ist nicht zur Ausführung gedacht.
# contains snippets, not for execution
# 

#---------------------------------------
# for
#

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

'''
output:
0
1
2
3
4
5
6
7
8
9
'''

for i in range(0,10):
    print(i, end=" ")

'''
output:
0 1 2 3 4 5 6 7 8 9
'''

#---------------------------------------
# for, indent
#

for i in range(0,10):
    print(i)
    print(".")

for i in range(0,10):
    print(i)
print(".")          # don't paste this line into shell

#---------------------------------------
# if, input, indent
#

name = input('please tape your name: ')
if name=="peter":
    print("hello again!")
else:
    print("hello!")
print(name)         # don't paste this line into shell


#---------------------------------------
# list
#

my_array = ["a","b","c","d","e"]

'''
>>> len(my_array)
5
>>> my_array.append("f")
>>> len(my_array)
6
>>> my_array
['a', 'b', 'c', 'd', 'e', 'f']
>>>
'''

#---------------------------------------
# lists
#

arr_rows = [
        ["#.."],
        [".#."],
        ["..#"]
      ]

arr = [
        ["#"],["."],["."],
        ["."],["#"],["."],
        ["."],["."],["#"]
      ]

#---------------------------------------
# function
#

def square(arg):
    return arg**2

square(4)

'''
output: 16
'''

#---------------------------------------
# list as a paremeter:
#

def dosomething( thelist ):
    for element in thelist:
        print element

dosomething( ['1','2','3'] )
alist = ['red','green','blue']
dosomething( alist )  

'''
Produces the output:
1
2
3
red
green
blue
'''

#---------------------------------------
# modulo operator:
#

'''
if c_pos < 0:
    c = cols-1
elif c_pos > cols-1:
    c = 0
else:
    c = c_pos
'''
# can be replaced with:
c = c_pos % cols

#---------------------------------------
#
#

print (list("." * 10))

'''
output:
['.', '.', '.', '.', '.', '.', '.', '.', '.', '.']
'''

#---------------------------------------
# traverse list:
#

arr = ["a", "b", "c"]
for pos in range(len(arr)):
    print(arr[pos], end=" ")

'''
output:
a b c
'''

# oder alternativ:

arr = ["a", "b", "c"]
for cell in arr:
    print(cell, end=" ")


#---------------------------------------
#
#

arr = [
["aa","ab","ac"],\
["ba","bb","bc"],\
["ca","cb","cc"]\
]
rows = len(arr)
cols = len(arr[0])
for row in range(rows):
    for col in range(cols):
        print(arr[row][col],end=" ")
    print()

'''
output:
aa ab ac
ba bb bc
ca cb cc
'''

# oder alternativ:

arr = [
["aa","ab","ac"],\
["ba","bb","bc"],\
["ca","cb","cc"]\
]

for row in arr:
    for cell in row:
        print(cell, end=" ")
    print()

#---------------------------------------
# https://stackoverflow.com/questions/29376970/correct-way-of-using-root-after-and-root-mainloop-in-tkinter
#

root = tk.Tk()
...
def do_one_iteration():
    ... your code here ...
    root.after(300000, do_one_iteration)

root.mainloop()