lehrkraefte:blc:informatik:ffprg1-2020:stringvar

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
lehrkraefte:blc:informatik:ffprg1-2020:stringvar [2022/03/24 13:33]
Ivo Blöchliger [Text Quadrate]
lehrkraefte:blc:informatik:ffprg1-2020:stringvar [2022/03/24 13:50] (current)
Ivo Blöchliger [Text Quadrate]
Line 76: Line 76:
     print(wort)     print(wort)
     a = a[-1]+a[:-1]     a = a[-1]+a[:-1]
 +</code>
 +<code python>
 +a = "PYTHON"
 +l = len(a)
 +a+=a
 +for i in range(l):
 +    print(a[i:i+l])
 </code> </code>
 </hidden> </hidden>
Line 100: Line 107:
     print     print
 </code> </code>
 +Die Idee
 <code python textquadrat3.py> <code python textquadrat3.py>
 a = "PYTHON" a = "PYTHON"
-w = a + a[-2::-1]  # Wort plus Wort rückwärts+w = a + a[-2::-1]  # Wort plus Wort rückwärts ohne letzten Buchstaben
 for i in range(len(a)): for i in range(len(a)):
     wort = ""     wort = ""
     for j in range(len(a)):     for j in range(len(a)):
-        wort += w[i+j] + " "+        wort += w[i+j] + " "      # Alle Buchstaben auf einer Diagonalen haben die gleiche Summe i+j
     print(wort)     print(wort)
 </code> </code>
  • lehrkraefte/blc/informatik/ffprg1-2020/stringvar.1648125226.txt.gz
  • Last modified: 2022/03/24 13:33
  • by Ivo Blöchliger