Advertisement
MartijnBioinformatic

Untitled

Oct 20th, 2019
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. def main():
  2.     fun1()
  3.     print("4. ", fun2())
  4.     print("5. ", fun2(9))
  5.     print("6. ", fun2(p2=7))
  6.     print("7. ", fun2(1, 9).count("e"))
  7.     print("8. ", fun3(7, 0))
  8.     print("9. ", fun3(7, 7))
  9.     print("10.", fun3("zeven", 10))
  10.  
  11.  
  12. def fun1():
  13.     a = 7
  14.     print("1. ", a == 7)
  15.     if a > 5:
  16.         a += 3
  17.         print("2. ", a)
  18.     else:
  19.         print("2. ", a * "a")
  20.     a = 4
  21.     b = 0
  22.     while a < 10:
  23.         a = a + 1
  24.         b = b + 1
  25.     print("3. ", b)
  26.  
  27.  
  28. def fun2(p1=7, p2=8):
  29.     if p1 > p2:
  30.         return "groter"
  31.     elif p1 == p2:
  32.         return "gelijk"
  33.     else:
  34.         return "kleiner"
  35.  
  36.  
  37. def fun3(p1, p2):
  38.     try:
  39.         getal1 = int(p1)
  40.         getal2 = int(p2)
  41.         uitkomst = int(getal1 / getal2)
  42.         return "abcd"[uitkomst]
  43.     except ZeroDivisionError:
  44.         return "e"
  45.     except ValueError:
  46.         return "f"
  47.     except:
  48.         return "g"
  49.  
  50.  
  51. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement