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
Last revision Both sides next revision
lehrkraefte:blc:informatik:ffprg1-2020:stringvar [2022/03/24 12:41]
Ivo Blöchliger
lehrkraefte:blc:informatik:ffprg1-2020:stringvar [2022/03/24 13:36]
Ivo Blöchliger [Text Quadrate]
Line 67: Line 67:
         sys.stdout.write(t[(i+j)%len(t)]+" ")         sys.stdout.write(t[(i+j)%len(t)]+" ")
     print     print
 +</code>
 +<code python textquadrat2.py>
 +a = "QUADRAT"
 +for i in range(len(a)):
 +    wort = ""
 +    for b in a:
 +        wort += b+" "
 +    print(wort)
 +    a = a[-1]+a[:-1]
 </code> </code>
 </hidden> </hidden>
Line 90: Line 99:
         sys.stdout.write(t[p]+" ")         sys.stdout.write(t[p]+" ")
     print     print
 +</code>
 +Die Idee
 +<code python textquadrat3.py>
 +a = "PYTHON"
 +w = a + a[-2::-1]  # Wort plus Wort rückwärts ohne letzten Buchstaben
 +for i in range(len(a)):
 +    wort = ""
 +    for j in range(len(a)):
 +        wort += w[i+j] + " "      # Alle Buchstaben auf einer Diagonalen haben die gleiche Summe i+j
 +    print(wort)
 </code> </code>
 </hidden> </hidden>
  • lehrkraefte/blc/informatik/ffprg1-2020/stringvar.txt
  • Last modified: 2022/03/24 13:50
  • by Ivo Blöchliger