// Numbas version: exam_results_page_options {"name": "Question 23 summation for loop", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"functions": {}, "ungrouped_variables": ["a"], "name": "Question 23 summation for loop", "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}], "extensions": [], "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": []}], "contributors": [{"name": "Amy Chadwick", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/505/"}]}]}], "contributors": [{"name": "Amy Chadwick", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/505/"}]}