math-exercises 3.0.100 → 3.0.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/exercises/math/calcul/arithmetics/whichMultipleAmI.js +1 -1
- package/lib/exercises/math/curve/sqrtCurvePoint.js +3 -3
- package/lib/exercises/math/dataRepresentations/barChartReading.d.ts +1 -1
- package/lib/exercises/math/dataRepresentations/barChartReading.js +1 -1
- package/lib/exercises/math/functions/basics/imageFunction.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/imageFunction.js +8 -8
- package/lib/exercises/math/functions/sqrt/compareSqrtValues.js +1 -1
- package/lib/exercises/math/geometry/euclidianConstructions/pointImageFromTranslation.d.ts.map +1 -1
- package/lib/exercises/math/geometry/euclidianConstructions/pointImageFromTranslation.js +41 -18
- package/lib/exercises/math/geometry/index.d.ts +1 -0
- package/lib/exercises/math/geometry/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/index.js +1 -0
- package/lib/exercises/math/geometry/optimisation/geometryExtremaReadingOnGraph.d.ts +8 -0
- package/lib/exercises/math/geometry/optimisation/geometryExtremaReadingOnGraph.d.ts.map +1 -0
- package/lib/exercises/math/geometry/optimisation/geometryExtremaReadingOnGraph.js +145 -0
- package/lib/exercises/math/geometry/optimisation/index.d.ts +4 -0
- package/lib/exercises/math/geometry/optimisation/index.d.ts.map +1 -0
- package/lib/exercises/math/geometry/optimisation/index.js +3 -0
- package/lib/exercises/math/geometry/optimisation/lengthIntervalOnPicture.d.ts +8 -0
- package/lib/exercises/math/geometry/optimisation/lengthIntervalOnPicture.d.ts.map +1 -0
- package/lib/exercises/math/geometry/optimisation/lengthIntervalOnPicture.js +93 -0
- package/lib/exercises/math/geometry/optimisation/lengthWithXOnPicture.d.ts +8 -0
- package/lib/exercises/math/geometry/optimisation/lengthWithXOnPicture.d.ts.map +1 -0
- package/lib/exercises/math/geometry/optimisation/lengthWithXOnPicture.js +99 -0
- package/lib/exercises/math/geometry/pythagore/index.d.ts +1 -0
- package/lib/exercises/math/geometry/pythagore/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/pythagore/index.js +1 -1
- package/lib/exercises/math/geometry/pythagore/triangleHeight.d.ts.map +1 -1
- package/lib/exercises/math/geometry/pythagore/triangleHeight.js +78 -32
- package/lib/exercises/math/geometry/vectors/constructions/traceOppositeVector.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/constructions/traceOppositeVector.js +31 -6
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorDifference.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorDifference.js +50 -10
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorMultiple.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorMultiple.js +39 -6
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorSum.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorSum.js +44 -7
- package/lib/exercises/math/probaStat/events/describeEvent.js +1 -1
- package/lib/exercises/math/probaStat/events/eventNotation.js +1 -1
- package/lib/exercises/math/probaStat/randomVariable/randomVariableStandardDeviation.js +4 -4
- package/lib/exercises/math/probaStat/stats1var/cumulativeSum.js +1 -1
- package/lib/exercises/math/probaStat/stats1var/getQuartileProportionQuestion.js +1 -1
- package/lib/exercises/math/probaStat/stats1var/interquartilesList.js +3 -3
- package/lib/exercises/math/probaStat/stats1var/interquartilesTable.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/interquartilesTable.js +22 -7
- package/lib/exercises/math/probaStat/stats1var/median.js +1 -1
- package/lib/exercises/math/probaStat/stats1var/medianList.js +1 -1
- package/lib/exercises/math/probaStat/stats1var/standardDeviationList.js +4 -4
- package/lib/exercises/math/probaStat/stats1var/standardDeviationTable.js +4 -4
- package/lib/exercises/math/probaStat/unionIntersectionProba.js +1 -1
- package/lib/exercises/math/python/inOutCalcul.js +1 -1
- package/lib/exercises/math/python/index.d.ts +6 -0
- package/lib/exercises/math/python/index.d.ts.map +1 -1
- package/lib/exercises/math/python/index.js +6 -0
- package/lib/exercises/math/python/pythonForLoopInstructionCompletion.d.ts +9 -0
- package/lib/exercises/math/python/pythonForLoopInstructionCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/pythonForLoopInstructionCompletion.js +129 -0
- package/lib/exercises/math/python/pythonIfStatementCompletion.d.ts +8 -0
- package/lib/exercises/math/python/pythonIfStatementCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/pythonIfStatementCompletion.js +114 -0
- package/lib/exercises/math/python/pythonRangeCompletion.d.ts +9 -0
- package/lib/exercises/math/python/pythonRangeCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/pythonRangeCompletion.js +105 -0
- package/lib/exercises/math/python/pythonSimpleFunctionInstructionCompletion.d.ts +8 -0
- package/lib/exercises/math/python/pythonSimpleFunctionInstructionCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/pythonSimpleFunctionInstructionCompletion.js +89 -0
- package/lib/exercises/math/python/pythonWhileStatementCompletion.d.ts +7 -0
- package/lib/exercises/math/python/pythonWhileStatementCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/pythonWhileStatementCompletion.js +87 -0
- package/lib/exercises/math/python/pythonWhileStatementOperationCompletion.d.ts +8 -0
- package/lib/exercises/math/python/pythonWhileStatementOperationCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/pythonWhileStatementOperationCompletion.js +120 -0
- package/lib/exercises/math/sampling/samplingFrequency.js +1 -1
- package/lib/index.d.ts +32 -0
- package/lib/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interquartilesTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/interquartilesTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;
|
|
1
|
+
{"version":3,"file":"interquartilesTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/interquartilesTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAqHF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAcrD,CAAC"}
|
|
@@ -19,7 +19,7 @@ const getAnswer = (identifiers) => {
|
|
|
19
19
|
return (thrid - first).frenchify();
|
|
20
20
|
};
|
|
21
21
|
const getInstruction = (identifiers) => {
|
|
22
|
-
return `Calculer l'écart
|
|
22
|
+
return `Calculer l'écart interquartile de la série statistique suivante :
|
|
23
23
|
|
|
24
24
|
${mdTable([
|
|
25
25
|
["$x_i$", ...identifiers.sortedValues.map((e) => `$${e.frenchify()}$`)],
|
|
@@ -28,13 +28,28 @@ ${mdTable([
|
|
|
28
28
|
`;
|
|
29
29
|
};
|
|
30
30
|
const getHint = (identifiers) => {
|
|
31
|
-
return `L'écart
|
|
31
|
+
return `L'écart interquartile est la différence entre le troisième quartile et le premier quartile, c'est à dire $Q_3-Q_1$.`;
|
|
32
32
|
};
|
|
33
33
|
const getCorrection = (identifiers) => {
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
|
|
34
|
+
const { effectifs, sortedValues } = identifiers;
|
|
35
|
+
const first = firstQuartile(sortedValues, effectifs);
|
|
36
|
+
const thrid = thirdQuartile(sortedValues, effectifs);
|
|
37
|
+
const n = effectifs.reduce((acc, curr) => acc + curr, 0);
|
|
38
|
+
return `On dresse le tableau des effectifs cumulés :
|
|
39
|
+
|
|
40
|
+
${mdTable([
|
|
41
|
+
["$x_i$", ...sortedValues.map((e) => `$${e.frenchify()}$`)],
|
|
42
|
+
["$n_i$", ...effectifs.map((e) => `$${e.frenchify()}$`)],
|
|
43
|
+
[
|
|
44
|
+
"ECC",
|
|
45
|
+
...effectifs.map((e, i) => `$${effectifs
|
|
46
|
+
.slice(0, i + 1)
|
|
47
|
+
.reduce((acc, curr) => acc + curr)
|
|
48
|
+
.frenchify()}$`),
|
|
49
|
+
],
|
|
50
|
+
])}
|
|
51
|
+
|
|
52
|
+
Il y a $${n}$ valeurs dans cette liste.
|
|
38
53
|
|
|
39
54
|
Puisque $0,25 \\times ${n} ${approxOrEqual(0.25 * n, 2).join("")}$, le premier quartile est la valeur de rang $${Math.ceil(n / 4)}$. On a donc $Q_1 = ${first}$.
|
|
40
55
|
|
|
@@ -85,7 +100,7 @@ const getQuestionFromIdentifiers = (identifiers) => {
|
|
|
85
100
|
export const interquartilesTable = {
|
|
86
101
|
id: "interquartilesTable",
|
|
87
102
|
connector: "=",
|
|
88
|
-
label: "Calcul de l'écart
|
|
103
|
+
label: "Calcul de l'écart interquartile d'un tableau d'effectifs",
|
|
89
104
|
isSingleStep: true,
|
|
90
105
|
generator: (nb, opts) => getDistinctQuestions(() => getInterquartilesTableQuestion(opts), nb),
|
|
91
106
|
qcmTimer: 60,
|
|
@@ -13,7 +13,7 @@ ${mdTable([
|
|
|
13
13
|
["Effectif", ...randomEffectives.map((e) => dollarize(e))],
|
|
14
14
|
])}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Déterminer la médiane de cette série de valeurs.`;
|
|
17
17
|
};
|
|
18
18
|
const getAnswer = (identifiers) => {
|
|
19
19
|
const { randomEffectives, randomValues } = identifiers;
|
|
@@ -23,7 +23,7 @@ const getAnswer = (identifiers) => {
|
|
|
23
23
|
return round(sigma, 2).frenchify();
|
|
24
24
|
};
|
|
25
25
|
const getInstruction = (identifiers) => {
|
|
26
|
-
return `Calculer l'écart
|
|
26
|
+
return `Calculer l'écart type de la série statistique suivante :
|
|
27
27
|
|
|
28
28
|
$$
|
|
29
29
|
${identifiers.sortedValues.map((e) => e.frenchify()).join("\\ ; \\ ")}
|
|
@@ -38,7 +38,7 @@ $$
|
|
|
38
38
|
V = \\frac{(x_1-\\overline{x})^2 + (x_2-\\overline{x})^2 + \\ldots + (x_N-\\overline{x})^2}{N}
|
|
39
39
|
$$
|
|
40
40
|
|
|
41
|
-
Puis l'écart
|
|
41
|
+
Puis l'écart type est la racine carrée de la variance.`;
|
|
42
42
|
};
|
|
43
43
|
const getCorrection = (identifiers) => {
|
|
44
44
|
const n = identifiers.sortedValues.length;
|
|
@@ -77,7 +77,7 @@ ${alignTex([
|
|
|
77
77
|
["", ...approxOrEqual(vce, 2)],
|
|
78
78
|
])}
|
|
79
79
|
|
|
80
|
-
L'écart
|
|
80
|
+
L'écart type est donc :
|
|
81
81
|
|
|
82
82
|
$$
|
|
83
83
|
\\sigma = \\sqrt{V} ${approxOrEqual(sigma, 2).join("")}
|
|
@@ -115,7 +115,7 @@ const getQuestionFromIdentifiers = (identifiers) => {
|
|
|
115
115
|
export const standardDeviationList = {
|
|
116
116
|
id: "standardDeviationList",
|
|
117
117
|
connector: "=",
|
|
118
|
-
label: "Calcul de l'écart
|
|
118
|
+
label: "Calcul de l'écart type d'une liste de valeurs",
|
|
119
119
|
isSingleStep: true,
|
|
120
120
|
generator: (nb, opts) => getDistinctQuestions(() => getStandardDeviationListQuestion(opts), nb),
|
|
121
121
|
qcmTimer: 60,
|
|
@@ -24,7 +24,7 @@ const getAnswer = (identifiers) => {
|
|
|
24
24
|
return round(sigma, 2).frenchify();
|
|
25
25
|
};
|
|
26
26
|
const getInstruction = (identifiers) => {
|
|
27
|
-
return `Calculer l'écart
|
|
27
|
+
return `Calculer l'écart type de la série statistique suivante :
|
|
28
28
|
|
|
29
29
|
${mdTable([
|
|
30
30
|
["$x_i$", ...identifiers.sortedValues.map((e) => `$${e.frenchify()}$`)],
|
|
@@ -47,7 +47,7 @@ $$
|
|
|
47
47
|
V = \\frac{n_1(x_1-\\overline{x})^2 + \\ldots + n_N(x_N-\\overline{x})^2}{N}
|
|
48
48
|
$$
|
|
49
49
|
|
|
50
|
-
Puis l'écart
|
|
50
|
+
Puis l'écart type est la racine carrée de la variance.`;
|
|
51
51
|
};
|
|
52
52
|
const getCorrection = (identifiers) => {
|
|
53
53
|
const { sortedValues, effectifs } = identifiers;
|
|
@@ -87,7 +87,7 @@ ${alignTex([
|
|
|
87
87
|
["", ...approxOrEqual(vce, 2)],
|
|
88
88
|
])}
|
|
89
89
|
|
|
90
|
-
L'écart
|
|
90
|
+
L'écart type vaut alors :
|
|
91
91
|
|
|
92
92
|
$$
|
|
93
93
|
\\sigma = \\sqrt{V} ${approxOrEqual(sigma, 2).join("")}
|
|
@@ -131,7 +131,7 @@ const getQuestionFromIdentifiers = (identifiers) => {
|
|
|
131
131
|
export const standardDeviationTable = {
|
|
132
132
|
id: "standardDeviationTable",
|
|
133
133
|
connector: "=",
|
|
134
|
-
label: "Calcul de l'écart
|
|
134
|
+
label: "Calcul de l'écart type d'un tableau d'effectifs",
|
|
135
135
|
isSingleStep: true,
|
|
136
136
|
generator: (nb, opts) => getDistinctQuestions(() => getStandardDeviationTableQuestion(opts), nb),
|
|
137
137
|
qcmTimer: 60,
|
|
@@ -147,7 +147,7 @@ const getQuestionFromIdentifiers = (identifiers) => ({
|
|
|
147
147
|
});
|
|
148
148
|
export const unionIntersectionProba = {
|
|
149
149
|
id: "unionIntersectionProba",
|
|
150
|
-
label: "Calculer une probabilité via les formules de l
|
|
150
|
+
label: "Calculer une probabilité via les formules de l'union et de l'intersection",
|
|
151
151
|
isSingleStep: true,
|
|
152
152
|
generator: (nb, opts) => getDistinctQuestions(() => getUnionIntersectionProbaQuestion(opts), nb),
|
|
153
153
|
qcmTimer: 60,
|
|
@@ -95,7 +95,7 @@ const isAnswerValid = (ans, { answer }) => {
|
|
|
95
95
|
};
|
|
96
96
|
export const inOutCalcul = {
|
|
97
97
|
id: "inOutCalcul",
|
|
98
|
-
label: "Attribution de variables $1$",
|
|
98
|
+
label: "Attribution de variables $1$ (Python)",
|
|
99
99
|
isSingleStep: true,
|
|
100
100
|
generator: (nb) => getDistinctQuestions(getInOutCalculQuestion, nb),
|
|
101
101
|
qcmTimer: 60,
|
|
@@ -12,4 +12,10 @@ export * from "./whileLoopCount.js";
|
|
|
12
12
|
export * from "./conditionIfElse.js";
|
|
13
13
|
export * from "./variableAffectation.js";
|
|
14
14
|
export * from "./conditionIfElifElse.js";
|
|
15
|
+
export * from "./pythonRangeCompletion.js";
|
|
16
|
+
export * from "./pythonIfStatementCompletion.js";
|
|
17
|
+
export * from "./pythonWhileStatementCompletion.js";
|
|
18
|
+
export * from "./pythonWhileStatementOperationCompletion.js";
|
|
19
|
+
export * from "./pythonForLoopInstructionCompletion.js";
|
|
20
|
+
export * from "./pythonSimpleFunctionInstructionCompletion.js";
|
|
15
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,qCAAqC,CAAC;AACpD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,yCAAyC,CAAC;AACxD,cAAc,gDAAgD,CAAC"}
|
|
@@ -12,3 +12,9 @@ export * from "./whileLoopCount.js";
|
|
|
12
12
|
export * from "./conditionIfElse.js";
|
|
13
13
|
export * from "./variableAffectation.js";
|
|
14
14
|
export * from "./conditionIfElifElse.js";
|
|
15
|
+
export * from "./pythonRangeCompletion.js";
|
|
16
|
+
export * from "./pythonIfStatementCompletion.js";
|
|
17
|
+
export * from "./pythonWhileStatementCompletion.js";
|
|
18
|
+
export * from "./pythonWhileStatementOperationCompletion.js";
|
|
19
|
+
export * from "./pythonForLoopInstructionCompletion.js";
|
|
20
|
+
export * from "./pythonSimpleFunctionInstructionCompletion.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Exercise } from "../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
coeff: number;
|
|
4
|
+
iterations: number;
|
|
5
|
+
operation: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const pythonForLoopInstructionCompletion: Exercise<Identifiers>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=pythonForLoopInstructionCompletion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pythonForLoopInstructionCompletion.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/pythonForLoopInstructionCompletion.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA4HF,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CAAC,WAAW,CAkBpE,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { randint } from "../../../math/utils/random/randint.js";
|
|
4
|
+
import { random } from "../../../utils/alea/random.js";
|
|
5
|
+
import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
|
|
6
|
+
const getPropositions = (n, { answer, coeff, iterations, operation }) => {
|
|
7
|
+
const propositions = [];
|
|
8
|
+
addValidProp(propositions, answer, "raw");
|
|
9
|
+
tryToAddWrongProp(propositions, `\`${operation}${coeff}\``, "raw");
|
|
10
|
+
tryToAddWrongProp(propositions, `\`x${operation}${iterations}\``, "raw");
|
|
11
|
+
tryToAddWrongProp(propositions, `\`${coeff}\``, "raw");
|
|
12
|
+
return shuffleProps(propositions, n);
|
|
13
|
+
};
|
|
14
|
+
const getAnswer = (identifiers) => {
|
|
15
|
+
return `a${identifiers.operation}${identifiers.coeff}`;
|
|
16
|
+
};
|
|
17
|
+
const getInstruction = (identifiers) => {
|
|
18
|
+
let word = "";
|
|
19
|
+
const { coeff, iterations, operation } = identifiers;
|
|
20
|
+
switch (operation) {
|
|
21
|
+
case "+":
|
|
22
|
+
word = "l'additionner";
|
|
23
|
+
break;
|
|
24
|
+
case "-":
|
|
25
|
+
word = "le soustraire";
|
|
26
|
+
break;
|
|
27
|
+
case "*":
|
|
28
|
+
word = "le multiplier";
|
|
29
|
+
break;
|
|
30
|
+
case "/":
|
|
31
|
+
default:
|
|
32
|
+
word = "le diviser";
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
return `On considère la fonction en Python suivante. Cette fonction doit permettre, pour un paramètre \`a\` saisi en entrée, de ${word} à $${iterations}$ reprises par $${coeff}$, puis de renvoyer le résultat du calcul.
|
|
36
|
+
|
|
37
|
+
Par quoi faut-il remplacer les trois points ?
|
|
38
|
+
|
|
39
|
+
\`\`\`
|
|
40
|
+
def boucle(a):
|
|
41
|
+
for num in range(${iterations}):
|
|
42
|
+
a=...
|
|
43
|
+
return a
|
|
44
|
+
\`\`\`
|
|
45
|
+
`;
|
|
46
|
+
};
|
|
47
|
+
const getHint = (identifiers) => {
|
|
48
|
+
const { coeff, operation } = identifiers;
|
|
49
|
+
const fakeCoeff = randint(2, 10, [coeff]);
|
|
50
|
+
const fakeOperation = random(["+", "-", "*", "/"], [operation]);
|
|
51
|
+
const word = fakeOperation === "/"
|
|
52
|
+
? "diviser"
|
|
53
|
+
: fakeOperation === "+"
|
|
54
|
+
? "additionner"
|
|
55
|
+
: fakeOperation === "-"
|
|
56
|
+
? "soustraire"
|
|
57
|
+
: "multiplier";
|
|
58
|
+
return `Sers-toi de cet exemple : en Python, si l'on veut ${word} une variable \`x\` par $${fakeCoeff}$, on écrit :
|
|
59
|
+
|
|
60
|
+
\`\`\`
|
|
61
|
+
x = x${fakeOperation}${fakeCoeff}
|
|
62
|
+
\`\`\``;
|
|
63
|
+
};
|
|
64
|
+
const getCorrection = (identifiers) => {
|
|
65
|
+
const { coeff, iterations, operation } = identifiers;
|
|
66
|
+
const word = operation === "/"
|
|
67
|
+
? "diviser"
|
|
68
|
+
: operation === "+"
|
|
69
|
+
? "additionner"
|
|
70
|
+
: operation === "-"
|
|
71
|
+
? "soustraire"
|
|
72
|
+
: "multiplier";
|
|
73
|
+
return `On veut ${word} \`a\` par $${coeff}$ à chaque exécution de la boucle \`for\`. En python, cela se traduit par :
|
|
74
|
+
|
|
75
|
+
\`\`\`
|
|
76
|
+
a=a${operation}${coeff}
|
|
77
|
+
\`\`\``;
|
|
78
|
+
};
|
|
79
|
+
const getKeys = (identifiers) => {
|
|
80
|
+
return [];
|
|
81
|
+
};
|
|
82
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
83
|
+
try {
|
|
84
|
+
return ans === answer;
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
return handleVEAError(err);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const getPythonRangeCompletionQuestion = (ops) => {
|
|
91
|
+
const iterations = randint(2, 11);
|
|
92
|
+
const operation = random(["+", "-", "*", "/"]);
|
|
93
|
+
const coeff = randint(2, 11);
|
|
94
|
+
const identifiers = {
|
|
95
|
+
coeff,
|
|
96
|
+
iterations,
|
|
97
|
+
operation,
|
|
98
|
+
};
|
|
99
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
100
|
+
};
|
|
101
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
102
|
+
return {
|
|
103
|
+
answer: getAnswer(identifiers),
|
|
104
|
+
instruction: getInstruction(identifiers),
|
|
105
|
+
keys: getKeys(identifiers),
|
|
106
|
+
answerFormat: "raw",
|
|
107
|
+
identifiers,
|
|
108
|
+
hint: getHint(identifiers),
|
|
109
|
+
correction: getCorrection(identifiers),
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
export const pythonForLoopInstructionCompletion = {
|
|
113
|
+
id: "pythonForLoopInstructionCompletion",
|
|
114
|
+
label: "Compléter une instruction dans une boucle `for` en Python",
|
|
115
|
+
isSingleStep: true,
|
|
116
|
+
generator: (nb, opts) => getDistinctQuestions(() => getPythonRangeCompletionQuestion(opts), nb),
|
|
117
|
+
qcmTimer: 60,
|
|
118
|
+
freeTimer: 60,
|
|
119
|
+
getPropositions,
|
|
120
|
+
isAnswerValid,
|
|
121
|
+
subject: "Mathématiques",
|
|
122
|
+
getInstruction,
|
|
123
|
+
getHint,
|
|
124
|
+
getCorrection,
|
|
125
|
+
getAnswer,
|
|
126
|
+
getQuestionFromIdentifiers,
|
|
127
|
+
hasHintAndCorrection: true,
|
|
128
|
+
answerType: "QCU",
|
|
129
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Exercise } from "../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
ineq: string;
|
|
4
|
+
coeff: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const pythonIfStatementCompletion: Exercise<Identifiers>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=pythonIfStatementCompletion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pythonIfStatementCompletion.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/pythonIfStatementCompletion.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AA8GF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAqB7D,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { randint } from "../../../math/utils/random/randint.js";
|
|
4
|
+
import { random } from "../../../utils/alea/random.js";
|
|
5
|
+
import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
|
|
6
|
+
const getPropositions = (n, { answer, coeff, ineq }) => {
|
|
7
|
+
const propositions = [];
|
|
8
|
+
addValidProp(propositions, answer, "raw");
|
|
9
|
+
tryToAddWrongProp(propositions, `\`a<${coeff}\``, "raw");
|
|
10
|
+
tryToAddWrongProp(propositions, `\`a>${coeff}\``, "raw");
|
|
11
|
+
tryToAddWrongProp(propositions, `\`a<=${coeff}\``, "raw");
|
|
12
|
+
tryToAddWrongProp(propositions, `\`a>=${coeff}\``, "raw");
|
|
13
|
+
return shuffleProps(propositions, n);
|
|
14
|
+
};
|
|
15
|
+
const getAnswer = (identifiers) => {
|
|
16
|
+
const { coeff, ineq } = identifiers;
|
|
17
|
+
return `\`a${ineq}${coeff}\``;
|
|
18
|
+
};
|
|
19
|
+
const getInstruction = (identifiers) => {
|
|
20
|
+
const { coeff, ineq } = identifiers;
|
|
21
|
+
const word = ineq === "<"
|
|
22
|
+
? "strictement inférieur"
|
|
23
|
+
: ineq === ">"
|
|
24
|
+
? "strictement supérieur"
|
|
25
|
+
: ineq === "<="
|
|
26
|
+
? "inférieur ou égal"
|
|
27
|
+
: "supérieur ou égal";
|
|
28
|
+
return `On considère la fonction en Python suivante. Cette fonction doit permettre, pour un paramètre \`a\` saisi en entrée, de tester s'il est ${word} à $${coeff}$, et :
|
|
29
|
+
|
|
30
|
+
- si c'est le cas, de renvoyer le triple de \`a\`;
|
|
31
|
+
- sinon, de renvoyer le carré de \`a\`.
|
|
32
|
+
|
|
33
|
+
Par quoi faut-il remplacer les trois points ?
|
|
34
|
+
|
|
35
|
+
\`\`\`
|
|
36
|
+
def test(a):
|
|
37
|
+
if ...:
|
|
38
|
+
return a*3
|
|
39
|
+
else:
|
|
40
|
+
return a**2
|
|
41
|
+
\`\`\`
|
|
42
|
+
`;
|
|
43
|
+
};
|
|
44
|
+
const getHint = (identifiers) => {
|
|
45
|
+
return `En Python :
|
|
46
|
+
|
|
47
|
+
- "strictement inférieur à" s'écrit \`<\` ;
|
|
48
|
+
- "strictement supérieur à" s'écrit \`>\` ;
|
|
49
|
+
- "inférieur ou égal à" s'écrit \`<=\` ;
|
|
50
|
+
- "supérieur ou égal à" s'écrit \`>=\`.
|
|
51
|
+
`;
|
|
52
|
+
};
|
|
53
|
+
const getCorrection = (identifiers) => {
|
|
54
|
+
const { coeff, ineq } = identifiers;
|
|
55
|
+
const word = ineq === "<"
|
|
56
|
+
? "strictement inférieur"
|
|
57
|
+
: ineq === ">"
|
|
58
|
+
? "strictement supérieur"
|
|
59
|
+
: ineq === "<="
|
|
60
|
+
? "inférieur ou égal"
|
|
61
|
+
: "supérieur ou égal";
|
|
62
|
+
return `La condition \`if\` doit tester si \`a\` est ${word} à $${coeff}$. En python, cela se traduit par :
|
|
63
|
+
|
|
64
|
+
\`\`\`
|
|
65
|
+
if a${ineq}${coeff}:
|
|
66
|
+
\`\`\``;
|
|
67
|
+
};
|
|
68
|
+
const getKeys = (identifiers) => {
|
|
69
|
+
return ["a", "sup", "inf", "equal"];
|
|
70
|
+
};
|
|
71
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
72
|
+
try {
|
|
73
|
+
return ans === answer;
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
return handleVEAError(err);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const getPythonIfStatementCompletionQuestion = (ops) => {
|
|
80
|
+
const identifiers = {
|
|
81
|
+
coeff: randint(1, 11),
|
|
82
|
+
ineq: random(["<", ">", "<=", ">="]),
|
|
83
|
+
};
|
|
84
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
85
|
+
};
|
|
86
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
87
|
+
return {
|
|
88
|
+
answer: getAnswer(identifiers),
|
|
89
|
+
instruction: getInstruction(identifiers),
|
|
90
|
+
keys: getKeys(identifiers),
|
|
91
|
+
answerFormat: "raw",
|
|
92
|
+
identifiers,
|
|
93
|
+
hint: getHint(identifiers),
|
|
94
|
+
correction: getCorrection(identifiers),
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
export const pythonIfStatementCompletion = {
|
|
98
|
+
id: "pythonIfStatementCompletion",
|
|
99
|
+
label: "Compléter une instruction `if` en Python",
|
|
100
|
+
isSingleStep: true,
|
|
101
|
+
generator: (nb, opts) => getDistinctQuestions(() => getPythonIfStatementCompletionQuestion(opts), nb),
|
|
102
|
+
qcmTimer: 60,
|
|
103
|
+
freeTimer: 60,
|
|
104
|
+
getPropositions,
|
|
105
|
+
isAnswerValid,
|
|
106
|
+
subject: "Mathématiques",
|
|
107
|
+
getInstruction,
|
|
108
|
+
getHint,
|
|
109
|
+
getCorrection,
|
|
110
|
+
getAnswer,
|
|
111
|
+
getQuestionFromIdentifiers,
|
|
112
|
+
hasHintAndCorrection: true,
|
|
113
|
+
answerType: "QCU",
|
|
114
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Exercise } from "../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
coeff: number;
|
|
4
|
+
iterations: number;
|
|
5
|
+
operation: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const pythonRangeCompletion: Exercise<Identifiers>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=pythonRangeCompletion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pythonRangeCompletion.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/pythonRangeCompletion.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAgGF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAiBvD,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { randint } from "../../../math/utils/random/randint.js";
|
|
4
|
+
import { random } from "../../../utils/alea/random.js";
|
|
5
|
+
import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
|
|
6
|
+
const getPropositions = (n, { answer }) => {
|
|
7
|
+
const propositions = [];
|
|
8
|
+
addValidProp(propositions, answer);
|
|
9
|
+
while (propositions.length < n) {
|
|
10
|
+
tryToAddWrongProp(propositions, randint(1, 20).frenchify());
|
|
11
|
+
}
|
|
12
|
+
return shuffleProps(propositions, n);
|
|
13
|
+
};
|
|
14
|
+
const getAnswer = (identifiers) => {
|
|
15
|
+
return identifiers.iterations.frenchify();
|
|
16
|
+
};
|
|
17
|
+
const getInstruction = (identifiers) => {
|
|
18
|
+
let word = "";
|
|
19
|
+
const { coeff, iterations, operation } = identifiers;
|
|
20
|
+
switch (operation) {
|
|
21
|
+
case "+":
|
|
22
|
+
word = "l'additionner";
|
|
23
|
+
break;
|
|
24
|
+
case "-":
|
|
25
|
+
word = "le soustraire";
|
|
26
|
+
break;
|
|
27
|
+
case "*":
|
|
28
|
+
word = "le multiplier";
|
|
29
|
+
break;
|
|
30
|
+
case "/":
|
|
31
|
+
default:
|
|
32
|
+
word = "le diviser";
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
return `On considère la fonction en Python suivante. Cette fonction doit permettre, pour un paramètre \`a\` saisi en entrée, de ${word} à $${iterations}$ reprises par $${coeff}$, puis de renvoyer le résultat du calcul.
|
|
36
|
+
|
|
37
|
+
Par quoi faut-il remplacer les trois points ?
|
|
38
|
+
|
|
39
|
+
\`\`\`
|
|
40
|
+
def boucle(a):
|
|
41
|
+
for num in range(...):
|
|
42
|
+
a = a${operation}${coeff}
|
|
43
|
+
return a
|
|
44
|
+
\`\`\`
|
|
45
|
+
`;
|
|
46
|
+
};
|
|
47
|
+
const getHint = (identifiers) => {
|
|
48
|
+
return `En python, l'instruction \`range(b)\` génère une séquence d'entiers de $0$ à $b-1$.`;
|
|
49
|
+
};
|
|
50
|
+
const getCorrection = (identifiers) => {
|
|
51
|
+
const { coeff, iterations, operation } = identifiers;
|
|
52
|
+
return `En python, l'instruction \`range(b)\` génère une séquence d'entiers de $0$ à $b-1$. Cela permet donc de répéter une boucle $b$ fois.
|
|
53
|
+
|
|
54
|
+
Pour répéter $${iterations}$ fois la boucle, il faut donc remplacer les trois points par $${iterations}$.`;
|
|
55
|
+
};
|
|
56
|
+
const getKeys = (identifiers) => {
|
|
57
|
+
return [];
|
|
58
|
+
};
|
|
59
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
60
|
+
try {
|
|
61
|
+
return ans === answer;
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
return handleVEAError(err);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const getPythonRangeCompletionQuestion = (ops) => {
|
|
68
|
+
const iterations = randint(2, 11);
|
|
69
|
+
const operation = random(["+", "-", "*", "/"]);
|
|
70
|
+
const coeff = randint(2, 11);
|
|
71
|
+
const identifiers = {
|
|
72
|
+
coeff,
|
|
73
|
+
iterations,
|
|
74
|
+
operation,
|
|
75
|
+
};
|
|
76
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
77
|
+
};
|
|
78
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
79
|
+
return {
|
|
80
|
+
answer: getAnswer(identifiers),
|
|
81
|
+
instruction: getInstruction(identifiers),
|
|
82
|
+
keys: getKeys(identifiers),
|
|
83
|
+
answerFormat: "tex",
|
|
84
|
+
identifiers,
|
|
85
|
+
hint: getHint(identifiers),
|
|
86
|
+
correction: getCorrection(identifiers),
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
export const pythonRangeCompletion = {
|
|
90
|
+
id: "pythonRangeCompletion",
|
|
91
|
+
label: "Fonction avec boucle `for` : compléter une instruction `range`",
|
|
92
|
+
isSingleStep: true,
|
|
93
|
+
generator: (nb, opts) => getDistinctQuestions(() => getPythonRangeCompletionQuestion(opts), nb),
|
|
94
|
+
qcmTimer: 60,
|
|
95
|
+
freeTimer: 60,
|
|
96
|
+
getPropositions,
|
|
97
|
+
isAnswerValid,
|
|
98
|
+
subject: "Mathématiques",
|
|
99
|
+
getInstruction,
|
|
100
|
+
getHint,
|
|
101
|
+
getCorrection,
|
|
102
|
+
getAnswer,
|
|
103
|
+
getQuestionFromIdentifiers,
|
|
104
|
+
hasHintAndCorrection: true,
|
|
105
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Exercise } from "../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
m: number;
|
|
4
|
+
p: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const pythonSimpleFunctionInstructionCompletion: Exercise<Identifiers>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=pythonSimpleFunctionInstructionCompletion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pythonSimpleFunctionInstructionCompletion.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/pythonSimpleFunctionInstructionCompletion.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqFF,eAAO,MAAM,yCAAyC,EAAE,QAAQ,CAAC,WAAW,CAsBzE,CAAC"}
|