Olli Graf
1 year ago
9 changed files with 62 additions and 0 deletions
@ -0,0 +1,2 @@ |
|||||
|
./__pycache__ |
||||
|
renderhtml/__pycache__ |
@ -0,0 +1 @@ |
|||||
|
./__pycache__ |
@ -0,0 +1,15 @@ |
|||||
|
import sys |
||||
|
|
||||
|
def fib_generator(): |
||||
|
a,b = 0,1 |
||||
|
|
||||
|
while True: |
||||
|
yield a |
||||
|
a,b = b, a+b |
||||
|
|
||||
|
|
||||
|
fibo = fib_generator() |
||||
|
|
||||
|
|
||||
|
for _ in range(int(sys.argv[1])): |
||||
|
print(next(fibo)) |
@ -0,0 +1,6 @@ |
|||||
|
squares = [] |
||||
|
|
||||
|
for x in range(1,6): |
||||
|
squares.append(x**2) |
||||
|
|
||||
|
print(squares) |
@ -0,0 +1,3 @@ |
|||||
|
squares = [x **2 for x in range(1,6)] |
||||
|
|
||||
|
print(squares) |
@ -0,0 +1,11 @@ |
|||||
|
schueler = [ |
||||
|
{'name':'Simpson','vorname': 'Bart'}, |
||||
|
{'name':'Simpson','vorname':'Lisa'}, |
||||
|
{'name':'van Houten','vorname':'Milhouse'}, |
||||
|
{'name':'Wiggum','vorname':'Ralph'}, |
||||
|
{'name':'Jones','vorname':'Jimbo'} |
||||
|
] |
||||
|
|
||||
|
vornamen = [s['vorname'] for s in schueler if s['name'] == 'Simpson'] |
||||
|
|
||||
|
print(vornamen) |
@ -0,0 +1,4 @@ |
|||||
|
zahlen = [1,2,3,4,5,6,7,8,9,10] |
||||
|
|
||||
|
for n in zahlen: |
||||
|
print(n) |
@ -0,0 +1,19 @@ |
|||||
|
def gen_zahl(): |
||||
|
n = 0 |
||||
|
|
||||
|
while n < 10: |
||||
|
n += 1 |
||||
|
yield n |
||||
|
|
||||
|
zahlen = gen_zahl() |
||||
|
|
||||
|
print(next(zahlen)) |
||||
|
print(next(zahlen)) |
||||
|
print(next(zahlen)) |
||||
|
print(next(zahlen)) |
||||
|
print(next(zahlen)) |
||||
|
print(next(zahlen)) |
||||
|
print(next(zahlen)) |
||||
|
print(next(zahlen)) |
||||
|
print(next(zahlen)) |
||||
|
print(next(zahlen)) |
Loading…
Reference in new issue