// Numbas version: exam_results_page_options {"name": "Basic R: Part 4", "duration": 0, "metadata": {"description": "", "licence": "Creative Commons Attribution 4.0 International"}, "allQuestions": true, "shuffleQuestions": false, "percentPass": 0, "timing": {"allowPause": true, "timeout": {"action": "none", "message": ""}, "timedwarning": {"action": "none", "message": ""}}, "pickQuestions": 0, "navigation": {"onleave": {"action": "none", "message": ""}, "reverse": true, "allowregen": true, "showresultspage": "oncompletion", "preventleave": true, "browse": true, "showfrontpage": true}, "feedback": {"showtotalmark": true, "advicethreshold": 0, "allowrevealanswer": true, "feedbackmessages": [], "showactualmark": true, "showanswerstate": true, "intro": ""}, "type": "exam", "questions": [], "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": [{"name": "Question 17 function", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Amy Chadwick", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/505/"}], "functions": {}, "ungrouped_variables": ["x", "a"], "tags": [], "preamble": {"css": "", "js": ""}, "advice": "

a) In the first part, the function takes the value $\\var{a}$ as input, and returns $\\var{2*a}$, the value multiplied by $2$.

\n

b) In the second part, the function takes $y = \\var{2*a}$ as input (set in part a) and again returns the value multiplied by $2$.

", "rulesets": {}, "parts": [{"displayColumns": 0, "prompt": "

What is the value of $y$?

", "matrix": [0, 0, "1", 0], "shuffleChoices": false, "variableReplacements": [], "choices": ["

{2*x}

", "

2

", "

{2*a}

", "

{x}

"], "variableReplacementStrategy": "originalfirst", "maxMarks": "1", "distractors": ["", "", "", ""], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "1_n_2", "displayType": "radiogroup", "minMarks": 0}, {"displayColumns": 0, "prompt": "

What is the value of $z$?

", "matrix": ["1", 0, 0, 0], "shuffleChoices": false, "variableReplacements": [], "choices": ["

{4*a}

", "

{4*x}

", "

{2*x}

", "

{2*a}

"], "variableReplacementStrategy": "originalfirst", "maxMarks": "1", "distractors": ["", "", "", ""], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "1_n_2", "displayType": "radiogroup", "minMarks": 0}], "statement": "
> x = {x}
> fun1 = function(x) {
+ return(2*x)
+ }
> (y= fun1({a}))
> (z= fun1(y))
", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "variables": {"a": {"definition": "random(6..15#1)", "templateType": "randrange", "group": "Ungrouped variables", "name": "a", "description": ""}, "x": {"definition": "random(1..5#1)", "templateType": "randrange", "group": "Ungrouped variables", "name": "x", "description": ""}}, "metadata": {"description": "", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question", "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}]}, {"name": "Question 18 function", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Amy Chadwick", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/505/"}], "functions": {}, "ungrouped_variables": ["x", "z", "a"], "tags": [], "preamble": {"css": "", "js": ""}, "advice": "

a) This function takes a value, in this case $\\var{a}$ and multiplies it by a value $z$ which in this case is $\\var{z}$. Therefore our function gives $\\var{a}\\times\\var{z}=\\var{a*z}$.

\n

b) $x$ has been defined in line 1 and should not be confused with the argument to the function. So, taking the input $\\var{x}$, the function returns $\\var{x}\\times\\var{z}=\\var{x*z}$.

", "rulesets": {}, "parts": [{"displayColumns": 0, "prompt": "

What is the value of $y$?

", "matrix": [0, 0, "1", 0], "shuffleChoices": false, "variableReplacements": [], "choices": ["

{x}

", "

{{x}*{z}}

", "

{{a}*{z}}

", "

{a}

"], "variableReplacementStrategy": "originalfirst", "maxMarks": "1", "distractors": ["", "", "", ""], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "1_n_2", "displayType": "radiogroup", "minMarks": 0}, {"displayColumns": 0, "prompt": "

What is the value of $a$?

", "matrix": [0, "1", 0, 0], "shuffleChoices": false, "variableReplacements": [], "choices": ["

{{x}*{a}}

", "

{{x}*{z}}

", "

{x}

", "

{z}

"], "variableReplacementStrategy": "originalfirst", "maxMarks": "1", "distractors": ["", "", "", ""], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "1_n_2", "displayType": "radiogroup", "minMarks": 0}], "statement": "
> x = {x}
> fun1 = function(x) {
+ z = {z}
+ return (x*z)
+ }
> y = fun1({a})
> a = fun1(x)
", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "variables": {"a": {"definition": "random(6..10#1)", "templateType": "randrange", "group": "Ungrouped variables", "name": "a", "description": ""}, "x": {"definition": "random(-10..-1#1)", "templateType": "randrange", "group": "Ungrouped variables", "name": "x", "description": ""}, "z": {"definition": "random(2..10#1)", "templateType": "randrange", "group": "Ungrouped variables", "name": "z", "description": ""}}, "metadata": {"description": "", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question", "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}]}, {"name": "Question 19 function", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Amy Chadwick", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/505/"}], "functions": {}, "ungrouped_variables": ["a", "x", "b", "k"], "tags": [], "preamble": {"css": "", "js": ""}, "advice": "

Don't be confused by the function stating $x=\\var{x}$. This just represents the default of the function. So if you type fun1(), the function will set $x=\\var{x}$ and return ${\\var{b*x}}$.

\n

a) Our function returns $\\var{b}\\times\\var{a}=\\var{a*b}$.

\n

b) We are given $k=\\var{k}$. Our function takes $\\var{b}\\times k =\\var{b*k}$ as input and returns $\\var{b*k}\\times\\var{b}=\\var{k*b*b}$.

", "rulesets": {}, "parts": [{"displayColumns": 0, "prompt": "

What is the value of $y$?

", "matrix": [0, 0, "1", 0], "shuffleChoices": false, "variableReplacements": [], "choices": ["

{x}

", "

{{x}*{b}}

", "

{{b}*{a}}

", "

{{x}*{a}}

"], "variableReplacementStrategy": "originalfirst", "maxMarks": "1", "distractors": ["", "", "", ""], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "1_n_2", "displayType": "radiogroup", "minMarks": 0}, {"displayColumns": 0, "prompt": "

What is the value of $z$?

", "matrix": ["1", 0, 0, 0], "shuffleChoices": false, "variableReplacements": [], "choices": ["

{{b}*{b}*{k}}

", "

{{b}*{k}}

", "

{{k}*{a}}

", "

{x}

"], "variableReplacementStrategy": "originalfirst", "maxMarks": "1", "distractors": ["", "", "", ""], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "1_n_2", "displayType": "radiogroup", "minMarks": 0}], "statement": "
> fun1 = function(x={x}) {
+ return({b}*x)
+ }
> y = fun1({a})
> k = {k}
> z = fun1({b}*k)
", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "variables": {"a": {"definition": "random(5..10#1)", "templateType": "randrange", "group": "Ungrouped variables", "name": "a", "description": ""}, "x": {"definition": "random(-5..-1#1)", "templateType": "randrange", "group": "Ungrouped variables", "name": "x", "description": ""}, "k": {"definition": "random(2..4#1)", "templateType": "randrange", "group": "Ungrouped variables", "name": "k", "description": ""}, "b": {"definition": "random(2..4#1)", "templateType": "randrange", "group": "Ungrouped variables", "name": "b", "description": ""}}, "metadata": {"description": "", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question"}, {"name": "Question 20 TRUE/FALSE function", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Amy Chadwick", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/505/"}], "functions": {}, "ungrouped_variables": ["a", "b"], "tags": [], "preamble": {"css": "", "js": ""}, "advice": "

This function sets y = FALSE if x = {b}, or y = TRUE if x is unequal to {b}. Line 1 sets x = {a}, therefore y = TRUE

", "rulesets": {}, "parts": [{"displayColumns": 0, "prompt": "

What is the value of $y$?

", "matrix": ["1", 0], "shuffleChoices": false, "variableReplacements": [], "choices": ["

TRUE

", "

FALSE

"], "variableReplacementStrategy": "originalfirst", "maxMarks": "1", "distractors": ["", ""], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "1_n_2", "displayType": "radiogroup", "minMarks": 0}], "statement": "
> x = {a}
> if(x=={b}) {
y = FALSE
} else {
y = TRUE
}
", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "variables": {"a": {"definition": "random(1..5#1)", "templateType": "randrange", "group": "Ungrouped variables", "name": "a", "description": ""}, "b": {"definition": "random(6..10#1)", "templateType": "randrange", "group": "Ungrouped variables", "name": "b", "description": ""}}, "metadata": {"description": "", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question", "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}]}, {"name": "Question 21 else if functions", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Amy Chadwick", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/505/"}], "functions": {}, "ungrouped_variables": ["a", "b"], "tags": [], "preamble": {"css": "", "js": ""}, "advice": "

The conditional statement returns:

\n

$y=0$ of $x$ is greater than {a};

\n

$y=1$ if $x$ is less than or equal to {b};

\n

$y=2$ otherwise.

", "rulesets": {}, "parts": [{"distractors": ["", "", ""], "prompt": "

What is the value of $y$?

", "matrix": [0, "1", 0], "shuffleChoices": true, "variableReplacements": [], "choices": ["

0

", "

1

", "

2

"], "variableReplacementStrategy": "originalfirst", "displayType": "radiogroup", "maxMarks": 0, "marks": 0, "scripts": {}, "displayColumns": 0, "showCorrectAnswer": true, "type": "1_n_2", "minMarks": 0}], "statement": "
> x = {b}
> if(x > {a}) {
y = 0
} else if(x <= {b}) {
y = 1
} else {
y = 2
}
", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "variables": {"a": {"definition": "random(7..11#1)", "templateType": "randrange", "group": "Ungrouped variables", "name": "a", "description": ""}, "b": {"definition": "random(1..5#1)", "templateType": "randrange", "group": "Ungrouped variables", "name": "b", "description": ""}}, "metadata": {"notes": "", "description": "", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question", "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}]}, {"name": "Question 22 else if ", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Amy Chadwick", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/505/"}], "functions": {}, "ungrouped_variables": ["x", "a"], "tags": [], "preamble": {"css": "", "js": ""}, "advice": "

We are given that $x=\\var{x}$, which does not fit the criteria for $z=0$ or $z=1$ as these are both ranges that do not include $x=\\var{x}$.

", "rulesets": {}, "parts": [{"displayColumns": 0, "prompt": "

What is the value of $z$?

", "matrix": [0, 0, "1"], "shuffleChoices": false, "variableReplacements": [], "choices": ["

0

", "

1

", "

2

"], "variableReplacementStrategy": "originalfirst", "maxMarks": "1", "distractors": ["", "", ""], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "1_n_2", "displayType": "radiogroup", "minMarks": 0}], "statement": "
> x = {x}
> y = \"Male\"
> if(x > {{x}+{a}} & y == \"Female\"){
z = 0
} else if(x < {x} & y == \"Male\"){
z = 1
} else {
z = 2
}
", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "variables": {"a": {"definition": "random(1..5#1)", "templateType": "randrange", "group": "Ungrouped variables", "name": "a", "description": ""}, "x": {"definition": "random(1..10#1)", "templateType": "randrange", "group": "Ungrouped variables", "name": "x", "description": ""}}, "metadata": {"description": "", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question", "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}]}, {"name": "Question 23 summation for loop", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Amy Chadwick", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/505/"}], "functions": {}, "ungrouped_variables": ["a"], "tags": [], "preamble": {"css": "", "js": ""}, "advice": "

This for loop takes the value 'total' and adds $1$ to it everytime. It loops $\\var{a}$ times, with the beginning value of $0$.

\n

So it will go...

\n

0 + 1 = 1

\n

1 + 1 = 2

\n

2 + 1 = 3

\n

etc ...

\n

Therefore the final value for 'total' must be $\\var{a}$.

", "rulesets": {}, "parts": [{"displayColumns": 0, "prompt": "

What is the value of $x$?

", "matrix": [0, "1", 0, 0], "shuffleChoices": false, "variableReplacements": [], "choices": ["

0

", "

{a}

", "

{{a}+1}

", "

{{a}*{a}}

"], "variableReplacementStrategy": "originalfirst", "maxMarks": "1", "distractors": ["", "", "", ""], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "1_n_2", "displayType": "radiogroup", "minMarks": 0}], "statement": "
> total = 0
> for(blob in 1:{a}){
total = total + 1
}
> x = total
", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "variables": {"a": {"definition": "random(6..15#1)", "templateType": "randrange", "group": "Ungrouped variables", "name": "a", "description": ""}}, "metadata": {"description": "", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question", "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}]}, {"name": "Question 24 for loop ", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Amy Chadwick", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/505/"}], "functions": {}, "ungrouped_variables": ["a", "b"], "tags": [], "preamble": {"css": "", "js": ""}, "advice": "

This function initialises the variable 'total' to 0, and then increments its value by 1 each time that 'blob' is greater than {{a}-{b}}. Therefore it's value will be $\\var{a} - \\var{a-b}= \\var{b}$

", "rulesets": {}, "parts": [{"displayColumns": 0, "prompt": "

What is the value of $x$?

", "matrix": [0, 0, "1", 0], "shuffleChoices": false, "variableReplacements": [], "choices": ["

{a}

", "

{{a}-{b}}

", "

{b}

", "

{{b}-1}

"], "variableReplacementStrategy": "originalfirst", "maxMarks": "1", "distractors": ["", "", "", ""], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "1_n_2", "displayType": "radiogroup", "minMarks": 0}], "statement": "
> total = 0 
> for(blob in 1:{a}){
if(blob > {{a}-{b}}) {
total = total + 1
}
}
> x = total
", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "variables": {"a": {"definition": "random(10..20#1)", "templateType": "randrange", "group": "Ungrouped variables", "name": "a", "description": ""}, "b": {"definition": "random(3..9#1)", "templateType": "randrange", "group": "Ungrouped variables", "name": "b", "description": ""}}, "metadata": {"description": "", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question", "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}]}]}], "contributors": [{"name": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}, {"name": "Amy Chadwick", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/505/"}], "extensions": [], "custom_part_types": [], "resources": []}