Permalink
Browse files

functions

  • Loading branch information...
1 parent 835ff42 commit 7e35771b70f26a607453f90d829d97609ca6d629 @belbob committed Jan 17, 2012
Showing with 51 additions and 9 deletions.
  1. +3 −8 src/05_dictionary.py
  2. +11 −1 src/08_for_while_loops.py
  3. +37 −0 src/09_functions.py
View
11 src/05_dictionary.py
@@ -3,12 +3,7 @@
@author: robert
'''
-student1 = {'lname':'Stiernet','fname':'Gino'}
-student2 = {'lname':'Lau','fname':'Philip'}
+student = {'lname':'Stiernet','fname':'Gino','age':21}
-
-students = (student1,student2)
-print students
-
-for x in students:
- print x["lname"],x["fname"]
+print student
+print student['lname'],student['age']
View
12 src/08_for_while_loops.py
@@ -25,4 +25,14 @@
age={'Jesse':21,'Raf':23,'Niels':22}
for student in age:
- print student,age[student]
+ print student,age[student]
+
+#
+
+student1 = {'lname':'Stiernet','fname':'Gino'}
+student2 = {'lname':'Lau','fname':'Philip'}
+students = (student1,student2)
+print students
+
+for x in students:
+ print x["lname"],x["fname"]
View
37 src/09_functions.py
@@ -0,0 +1,37 @@
+'''
+Created on Jan 17, 2012
+
+@author: robert
+'''
+def student(naam):
+ return 'hallo ' + naam
+
+print student('Raf')
+
+def group (naam,vnaam,groep='PC1'):
+ return '%s %s volgt de opleiding %s' % (naam,vnaam,groep)
+
+print group ('Raf','Van Haver')
+print group ('Raf','Van Haver','PC2')
+
+def rapport (naam,vnaam,*punten):
+ print naam,vnaam
+ print punten
+ print 'gem. ',sum(punten)/len(punten)
+
+rapport ('Raf','Van Haver',68,34,92,34)
+
+def vakken (naam,vnaam,**vak):
+ print naam,vnaam
+ print vak
+
+vakken ('Raf','Van Haver',Nederlands=56,Engels=95,Godsdienst=23)
+
+vakpunten = {'Wiskunde':68,'Frans':34,'Technologie':92}
+
+vakken ('Raf','Van Haver',**vakpunten)
+
+
+
+
+

0 comments on commit 7e35771

Please sign in to comment.