aufgaben.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # -*- coding: utf-8 -*-
  2. from random import randint, choice
  3. def zweistellig_plus_zehner():
  4. x = randint(11, 99)
  5. y = randint(1, x//10)
  6. aufgabe = f"{ x - 10 * y } + { y }0 = ?"
  7. ergebnis = x
  8. return (aufgabe, ergebnis, 3)
  9. def zehner_minus_einstellig():
  10. x = randint(1, 89)
  11. aufgabe = f"{ (x//10 + 1) * 10 } - { (x//10 + 1) * 10 - x } = ?"
  12. ergebnis = x
  13. return (aufgabe, ergebnis, 3)
  14. def bis_zum_naechsten_zehner():
  15. x = randint(1, 8)
  16. y = randint(1, 9)
  17. aufgabe = f"Von { 10 * x + y } zum nächsten Zehner?"
  18. ergebnis = 10 - y
  19. return (aufgabe, ergebnis, 3)
  20. def minus_einstellig_ueber_zehnergrenze_hinweg_unter_100():
  21. x = randint(1, 9)
  22. y = randint(x, 9)
  23. z = randint(1, 9)
  24. aufgabe = f"{ z }{ x } - { y } = ?"
  25. ergebnis = (10 * z + x) - y
  26. return (aufgabe, ergebnis, 10)
  27. def minus_einstellig_unter_100():
  28. aufgabe, ergebnis = _minus(range(10,100), range(1,10))
  29. return aufgabe, ergebnis, 10
  30. def _minus(minuend: list, subtrahend: list):
  31. x = choice(minuend)
  32. y = choice(subtrahend)
  33. aufgabe = f"{ x } - { y } = ?"
  34. ergebnis = x - y
  35. return aufgabe, ergebnis
  36. def plus_10_bis_19_unter_100():
  37. aufgabe, ergebnis = _plus(range(1, 80), range(10, 20))
  38. return aufgabe, ergebnis, 10
  39. def _plus(summand_1: list, summand_2: list):
  40. x = choice(summand_1)
  41. y = choice(summand_2)
  42. aufgabe = f"{ x } + { y } = ?"
  43. ergebnis = x + y
  44. return aufgabe, ergebnis