# (c) david vajda
# 10/13/25
# std warm up/start up py3 excersize
def matrix_mul_rec (col3, col2, col1, i, n):
if i < n:
j = 0
while j < m:
y = 0
l = 0
while l < n:
y = y + col1 [i][l] * col2 [l][j]
l = l + 1
col3 [i][j] = y
j = j + 1
col3 = matrix_mul_rec (col3, col2, col1, i+1, n)
return col3
def faculty (n):
nf = 1
while n > 0:
nf = nf * n
n = n - 1
return nf
print ("(c) david vajda")
print ("10/13/25")
print ("std warm up/start up py3 excersize")
print ("hello world")
print ("good morning in the sun")
print ("it's monday the 13th")
print ("not oct red")
print ("but oct 13th 10/13")
print ("let's enjoy the heat")
string_list = [ "hello world", "good morning in the sun", "it's monday the 13th", "not oct red", "but oct 13th 10/13", "let's enjoy the heat"]
n = len (string_list)
i = 0
while i < n:
print (string_list [i], end=", ")
i = i + 1
n=7
print ("die fakultaet", n, "! von ", n, " ist ", faculty (n))
i = 0
while i < 7:
print (i, faculty(i))
i = i + 1
# zum aufwaermen matrizenmultiplikation
row1 = []
col1 = []
row2 = []
col2 = []
row3 = []
col3 = []
import random
random.seed ()
n = 5
m = 5
valmax = 0x0f
valmin = 0x01
# i = 0
# while i < n:
# row1 = row1 + [random.randint (valmin, valmax)]
# i = i + 1
j = 0
while j < m:
i = 0
while i < n:
row1 = row1 + [random.randint (valmin, valmax)]
i = i + 1
col1 = col1 + [row1]
row1 = []
j = j + 1
print (col1)
j = 0
while j < m:
i = 0
while i < n:
row2 = row2 + [random.randint (valmin, valmax)]
i = i + 1
col2 = col2 + [row2]
row2 = []
j = j + 1
print (col2)
j = 0
while j < m:
i = 0
while i < n:
row3 = row3 + [random.randint (valmin, valmax)]
i = i + 1
col3 = col3 + [row3]
row3 = []
j = j + 1
print (col3)
# da die row (engl.: zeile) vom speicher her, in der matrix landen
# row aber allenfalls speicherleiche bleibt, aber geloesch ist
# brauchen wir nicht variablen row1, row2, row3
# sondern row reicht und wir brauchen nicht den namen col1, col2, col3
# koennen den genauso nehmen, ist aber unsere Matrix M1, M2, M3, ...
# jetzt multiplizieren wir die matrizen, zeile erste matrix n-tes element
# spalte 2. matrix, n-tes element spalte, bzw. bzw m mit m = n
# ...
# hier sieht man die 3. zieloperand, produkt = multiplikator * multiplikant
# zieloperand = quelloperand2 op quelloperand1
# haetten wir nicht initialisieren, dafuer ist der zieloperand schon mal da
i = 0
while i < n:
j = 0
while j < m:
y = 0
l = 0
while l < n:
y = y + col1 [i][l] * col2 [l][j]
l = l + 1
col3 [i][j] = y
j = j + 1
i = i + 1
print (col3)
print ("\\documentclass [a4paper]{article}")
print ("\\usepackage{german,amsmath,amsfonts}")
print ("\\author{david vajda}")
print ("\\title{10/13/25,matrix per python 3, multiplikiation}")
print ("\\begin{document}")
print ("\\maketitle")
print ("$$")
print ("\\left(")
print ("\\begin{tabular}{ccccc}")
i = 0
while i < n:
j = 0
while j < m - 1:
print (col1[i][j], end=" & ")
j = j + 1
print (col1 [i][j], "\\\\")
i = i + 1
print ("\\end{tabular}")
print ("\\right)")
print ("\\cdot")
print ("\\left(")
print ("\\begin{tabular}{ccccc}")
i = 0
while i < n:
j = 0
while j < m - 1:
print (col2[i][j], end=" & ")
j = j + 1
print (col2 [i][j], "\\\\")
i = i + 1
print ("\\end{tabular}")
print ("\\right)")
print ("=")
print ("\\left(")
print ("\\begin{tabular}{ccccc}")
i = 0
while i < n:
j = 0
while j < m - 1:
print (col3[i][j], end=" & ")
j = j + 1
print (col3 [i][j], "\\\\")
i = i + 1
print ("\\end{tabular}")
print ("\\right)")
print ("$$")
print ("\\end{document}")
print (matrix_mul_rec (col3, col2, col1, 0, n))