

#--------------------------------topic: --------------------------------#




#################################Slide 4#######################################
def nextState(input_data):
    n = len(input_data)
    output_data = []
    for i in range(0, n):
        output_data.append([])
        for j in range(0, n):
            output_data[i].append(False)
    for i in range(0, n):
        for j in range(0, n):
            count = 0
            if i > 0 and j > 0 and input_data[i-1][j-1] == True:
                count += 1
            if i > 0 and input_data[i-1][j] == True:
                count += 1
            if i > 0 and j < (n-1) and input_data[i-1][j+1] == True:
                count += 1
            if j < (n-1) and input_data[i][j+1] == True:
                count += 1
            if i < (n-1) and j < (n-1) and input_data[i+1][j+1] == True:
                count += 1
            if i < (n - 1) and input_data[i+1][j] == True:
                count += 1
            if i < (n - 1) and j > 0 and input_data[i+1][j-1] == True:
                count += 1
            if j > 0 and input_data[i][j-1] == True:
                count += 1
            if input_data[i][j] == True and count < 2:
                output_data[i][j] = False
            elif input_data[i][j] == True and (count == 2 or count == 3):
                output_data[i][j] = True
            elif input_data[i][j] == True and count > 3:
                output_data[i][j] = False
            elif input_data[i][j] == False and count == 3:
                output_data[i][j] = True
    return output_data



#--------------------------------topic: --------------------------------#




#################################Slide 2#######################################
A = [3, 6, 12, 312, 9, -3]
c = len(A)
print(c)






#################################Slide 3#######################################
a = 10
b = 20
c = myfirstfunction(a,b)
print(c)





#################################Slide 3#######################################
def myfirstfunction (x, y):
    print("hi!")
    return x + y






#################################Slide 4#######################################
def myfirstfunction (x, y):
    print("hi!")
    return x + y

a = 10
b = 20
c = myfirstfunction(a,b)
print(c)






#################################Slide 5#######################################
def myfirstfunction (x, y):
    print("hi!")
    return x + y

a = 10
b = 20
c = myfirstfunction(a,b)
print(c)






#################################Slide 5#######################################
a = 10
b = 20

x = a
y = b
print("hi!")
c = x + y

print(c)





#################################Slide 7#######################################
print( min(-1, -5, -3, 3.4) )









#################################Slide 7#######################################
print( max(-1, -5, -3, 3.4, 99, 99.98, 99.98001) )







#################################Slide 8#######################################
print( abs(-1.44) )






#################################Slide 8#######################################
a = 9.43341
b = int(a)
print(b)






#################################Slide 9#######################################
import math

a = 9.454
b = math.sqrt(a)
print(b)






#################################Slide 9#######################################
a = 9.454
b = sqrt(a)
print(b)






#################################Slide 11#######################################
def echange(x, y):
    tmp = x
    x = y
    y = tmp

a = 10
b = 20
print("Before:", a, b)
echange(a, b)
print("After:", a, b)






#################################Slide 12#######################################
a = 10
b = 20
print("Before:", a, b)

x = a
y = b
tmp = x
x = y
y = tmp

print("After:", a, b)






#################################Slide 12#######################################
def echange(x, y):
    tmp = x
    x = y
    y = tmp

a = 10
b = 20
print("Before:", a, b)
echange(a, b)
print("After:", a, b)






#################################Slide 13#######################################
def myfunction(x):
    x = 20

a = 10
print("Before:", a)
myfunction(a)
print("After:", a)






#################################Slide 13#######################################
def myfunction(x):
    x = "again"

a = "hello"
print("Before:", a)
myfunction(a)
print("After:", a)






#################################Slide 13#######################################
def myfunction(x):
    x = False

a = True
print("Before:", a)
myfunction(a)
print("After:", a)






#################################Slide 13#######################################
a = 10
print("Before: ", a)

x = a
x = 20

print("After:", a)






#################################Slide 14#######################################
def mysecondfunction(B):
    tmp = B[0]
    B[0] = B[1]
    B[1] = tmp

A = [10, 20]
print("Before:", A[0], A[1])
mysecondfunction(A)
print("After:", A[0], A[1])






#################################Slide 14#######################################
A = [10, 20]
print("Before:", A[0], A[1])

B = A
tmp = B[0]
B[0] = B[1]
B[1] = tmp

print("After:", A[0], A[1])






#################################Slide 15#######################################
def computeMaximum(A):
    max = A[0]

    for i in range(0, len(A)):
        if A[i] > max: 
            max = A[i]

    return max

print("Maximum of A is:", computeMaximum( [3, 23, 22, 12, -3, 100, 80] )






#################################Slide 15#######################################
A = [3, 23, 22, 12, -3, 100, 80]

max = A[0]
for i in range(0, len(A)):
    if A[i] > max: 
        max = A[i]

print("Maximum of A is:", max)






#################################Slide 16#######################################
def computeMaximum(A):
    max_index = 0

    for i in range(0, len(A)):
        if A[i] > A[max_index]: 
            max_index = i

    print("Maximum of A is:", A[max_index], "at index:", max_index)

computeMaximum( [3, 23, 22, 12, -3, 100, 80] )






#################################Slide 17#######################################
a = 10
b = 20
c = myfirstfunction(a,b)
print(c)

def myfirstfunction (x, y):
    print("hi!")
    return x + y





#################################Slide 18#######################################
def mysecondfunction(x):
    return 2*x, 3*x, 4*x

a,b,c = mysecondfunction(5)
print(a,b,c)






#################################Slide 20#######################################
a = 10

def mysecondfunction(b):
    print("in:", a)

mysecondfunction( a + 10 )
print("out:", a)






#################################Slide 20#######################################
a = 10

def mysecondfunction(a):
    print("in:", a)

mysecondfunction( a + 10 )
print("out:", a)






#################################Slide 21#######################################
a = 10

def f():
    a = 20

print("a1: ", a)
f()
print("a2: ", a)





#################################Slide 21#######################################
a = 10

def f():
    global a
    a = 20

print("a1:", a)
f()
print("a2:", a)





#################################Slide 23#######################################
def f(x = 'hello',y):
    print("x: ", x, " and y: ", y)

f(10,4)
 





#################################Slide 23#######################################
def f(x,y='hi'):
    print("x: ", x, " and y: ", y)

f(10,4)
f(10)





#################################Slide 24#######################################
def f(x,y):
    print( x**2 )
    print("My name is: ", y)

f(5, "john")






#################################Slide 24#######################################
def f(x,y):
    print( x**2 )
    print("My name is: ", y)

f("john", 5)






#################################Slide 24#######################################
def f(x,y):
    print( x**2 )
    print("My name is: ", y)

f(y="john", x=5)






#################################Slide 25#######################################
def f(*, x,y):
  print("x: ", x, " and y: ", y)

f(x=10,y=4)





#################################Slide 25#######################################
def f(*, x='hello',y):
  print("x: ", x, " and y: ", y)

f(x=10,y=4)
f(y=2)
f(y=5, x=True)





#################################Slide 25#######################################
def f(*, x,y):
  print("x: ", x, " and y: ", y)

f(10, 4)





#################################Slide 27#######################################
def f(g):
    print( type(g) )
    g("hi!")


f( print )





#################################Slide 27#######################################
def k(x,y):
    print(x, "+", y, "is:", x+y)

def f(g):
    print( type(g) )
    g(4,10)


f(k)




#################################Slide 29#######################################
A = [3, 7, 1, 6, 788]

A.append("hello")
print(A)



#################################Slide 29#######################################
A = [3, 7, 1, 6, 788]

n = len(A)

print(n)



#################################Slide 29#######################################
def mysecondfunction(x):
    return 2*x, 3*x, 4*x

a,b,c = mysecondfunction(5)
print(a,b,c)






#################################Slide 29#######################################
n = 10
n.append(20)

