Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
lehrkraefte:blc:informatik:glf4-20:simulation:python-repe [2021/03/27 10:04] Ivo Blöchliger |
lehrkraefte:blc:informatik:glf4-20:simulation:python-repe [2021/04/01 07:33] Ivo Blöchliger [Zufallszahlen] |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Python Repetition / Cheat Sheet ====== | ====== Python Repetition / Cheat Sheet ====== | ||
+ | * Gehen Sie Beispiele von oben bis unten durch. | ||
+ | * Kopieren Sie jeweils den Code in TigerJython und führen Sie das jeweilige Programm aus. | ||
+ | * Versuchen Sie, jede Zeile der Programm zu verstehen. Wenn Sie nicht sicher sind, fügen sie '' | ||
+ | * Wenn Sie eine Zeile nicht verstehen, stellen Sie Fragen und/oder " | ||
+ | * Das Ziel ist nicht, alles auswendig zu wissen, aber zu wissen, was möglich ist und wo die Information zu finden ist. | ||
===== Variablen, Strings vs. Zahlen ===== | ===== Variablen, Strings vs. Zahlen ===== | ||
=== Variablen mit Zahlen === | === Variablen mit Zahlen === | ||
Line 9: | Line 13: | ||
print(bar) | print(bar) | ||
print(foo-bar) # Ausgabe 20 | print(foo-bar) # Ausgabe 20 | ||
+ | print(" | ||
+ | print(5**3) | ||
+ | print(" | ||
+ | print(2**0.5) | ||
</ | </ | ||
Line 64: | Line 72: | ||
if z%15 == 0: # z%15 ist der Rest der Division durch 15. Um Gleichheit zu prüfen wird das doppelte Gleichheitszeichen verwendet | if z%15 == 0: # z%15 ist der Rest der Division durch 15. Um Gleichheit zu prüfen wird das doppelte Gleichheitszeichen verwendet | ||
print(" | print(" | ||
- | print(" | + | print(" |
elif z%5 == 0: # Wenn die erste Bedingung falsch ist, und z%5==0 | elif z%5 == 0: # Wenn die erste Bedingung falsch ist, und z%5==0 | ||
print(" | print(" | ||
Line 71: | Line 79: | ||
else: # Wenn keine der obigen Bedingungen wahr ist | else: # Wenn keine der obigen Bedingungen wahr ist | ||
print(" | print(" | ||
- | print(" | + | print(" |
print(" | print(" | ||
</ | </ | ||
Line 97: | Line 105: | ||
quadratzahlen.append(i*i) | quadratzahlen.append(i*i) | ||
print(" | print(" | ||
+ | print(quadratzahlen) | ||
</ | </ | ||
Line 145: | Line 154: | ||
return zahlen | return zahlen | ||
- | foos = meineListe() | + | foos = meineListe() |
print(foos) | print(foos) | ||
</ | </ | ||
Line 161: | Line 170: | ||
<code python> | <code python> | ||
from random import randrange | from random import randrange | ||
- | for i in range(1, | + | for i in range(1, |
- | print(" | + | print(" |
</ | </ | ||
Uniform verteilte reelle Zahlen im Intervall $[0,1)$. | Uniform verteilte reelle Zahlen im Intervall $[0,1)$. |