Skip to content

Commit

Permalink
a few solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
magnhaug committed Mar 14, 2012
1 parent bc0f2e4 commit 7946087
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions slides/del2.html
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@

 

.python
>>> generator = (i for i in range(10))
>>> print generator
<generator object <genexpr> at 0x10ff3e410>
Expand Down Expand Up @@ -366,6 +367,29 @@

# Pause!

---

### Løsninger:

Lag en list comprehension som lister opp alle partall under 20, og print dem

.python
>>> partall = [i for i in xrange(20) if i%2==0]
>>> for i in partall:
... print i,
...
0 2 4 6 8 10 12 14 16 18

Lag et generator expression som gjør det samme. Print dem.

.python
>>> partall = (i for i in xrange(20) if i%2==0)
>>> for i in partall:
... print i,
...
0 2 4 6 8 10 12 14 16 18


---

# Funksjoner
Expand Down

0 comments on commit 7946087

Please sign in to comment.