From 35a9e63d9a0c4ea4ffe85fe0226f1a39e8867f98 Mon Sep 17 00:00:00 2001 From: Miguel Barão Date: Mon, 25 Mar 2024 17:10:48 +0000 Subject: [PATCH] change demo/math/addition --- demo/math/addition/addition-two-digits.py | 20 -------------------- demo/math/addition/addition.py | 34 ++++++++++++++++++++++++++++++++++ demo/math/addition/questions.yaml | 23 +++-------------------- 3 files changed, 37 insertions(+), 40 deletions(-) delete mode 100755 demo/math/addition/addition-two-digits.py create mode 100755 demo/math/addition/addition.py diff --git a/demo/math/addition/addition-two-digits.py b/demo/math/addition/addition-two-digits.py deleted file mode 100755 index c9a5519..0000000 --- a/demo/math/addition/addition-two-digits.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 - -import random -import sys - -a = int(sys.argv[1]) -b = int(sys.argv[2]) - -x = random.randint(a, b) -y = random.randint(a, b) -r = x + y - -print(f'''--- -type: text -title: Adição de números com 2 algarismos -text: | - Qual o resultado da soma ${x}+{y}$? -correct: ['{r}'] -solution: | - O resultado é {r}.''') diff --git a/demo/math/addition/addition.py b/demo/math/addition/addition.py new file mode 100755 index 0000000..b85f510 --- /dev/null +++ b/demo/math/addition/addition.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + +''' +This question generator expects two integer arguments. +These are the range for the number of coins in each pocket. +''' + +import random +import sys + +a = int(sys.argv[1]) +b = int(sys.argv[2]) + +x, y = random.sample(range(a, b), k=2) +r = x + y + +pocket1, pocket2 = random.sample(['left pocket', 'right pocket', 'wallet', + 'safe at home'], k=2) + +currency = random.choice(['Euros', 'US dollars', 'British pounds']) + +print(f'''--- +type: text +title: Adding two numbers +text: | + Suppose you have {x} {currency} in your {pocket1} and {y} in your + {pocket2}. + How many {currency} do you have? + + Just answer the number, for example `42`. +transform: ['trim'] +correct: ['{r}'] +solution: | + You have a total of {r} {currency}.''') diff --git a/demo/math/addition/questions.yaml b/demo/math/addition/questions.yaml index 903dace..bbcaec0 100644 --- a/demo/math/addition/questions.yaml +++ b/demo/math/addition/questions.yaml @@ -1,23 +1,6 @@ --- # --------------------------------------------------------------------------- - type: generator - ref: addition-two-digits - script: addition-two-digits.py - args: [10, 20] - -# --------------------------------------------------------------------------- -- type: checkbox - ref: addition-properties - title: Propriedades da adição - text: Indique quais as propriedades que a adição satisfaz. - options: - # right - - Existência de elemento neutro, $x+0=x$. - - Existência de inverso aditivo (simétrico), $x+(-x)=0$. - - Propriedade associativa, $(x+y)+z = x+(y+z)$. - - Propriedade comutativa, $x+y=y+x$. - # wrong - - Existência de elemento absorvente, $x+1=1$. - correct: [1, 1, 1, 1, 0] - solution: | - A adição não tem elemento absorvente. + ref: addition + script: addition.py + args: [2, 20] -- libgit2 0.21.2