Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 11 additions and 10 deletions.
  1. +11 −10 slides/del2.html
View
21 slides/del2.html
@@ -91,20 +91,15 @@
List comprehensions kan også gjøres med nestede løkker:
-Eksmpel med 2 nivåer:
+Eksmpel med 3 nivåer:
.python
- >>> navn = ['Magnus', 'Kjetil']
- >>> hilsen = ['Hei', 'Hallo', 'HAI']
- >>> [h+' '+n for h in hilsen for n in navn]
- ['Hei Magnus', 'Hei Kjetil', 'Hallo Magnus', 'Hallo Kjetil', 'HAI Magnus', 'HAI Kjetil']
+ >>> bokstaver = ['x','y','x']
+ >>> [a+b+c for a in bokstaver for b in bokstaver for c in bokstaver]
+ ['xxx', 'xxy', 'xxx', 'xyx', 'xyy', 'xyx', 'xxx', 'xxy', 'xxx', 'yxx', 'yxy', 'yxx', 'yyx', 'yyy',
+ 'yyx', 'yxx', 'yxy', 'yxx', 'xxx', 'xxy', 'xxx', 'xyx', 'xyy', 'xyx', 'xxx', 'xxy', 'xxx']
-Eller 5...
- .python
- >>> [str(a)+str(b)+str(c)+str(d)+str(e) for a in range(10) for b in range(10) \
- ... for c in range(10) for d in range(10) for e in range(10)]
- ['00000', '00001', '00002', '00003', ..., '99996', '99997', '99998', '99999']
---
@@ -367,6 +362,12 @@
---
+.middle.center
+
+# Pause!
+
+---
+
# Funksjoner
Funksjoner i python er *førsteklasses*, og vi kan derfor gjøre mer med dem enn vi er vant med fra Java.

No commit comments for this range

Something went wrong with that request. Please try again.