// Numbas version: finer_feedback_settings {"name": "Question 24 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", "b"], "name": "Question 24 for loop ", "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}], "extensions": [], "statement": "> total = 0", "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": "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/"}]}
> for(blob in 1:{a}){
if(blob > {{a}-{b}}) {
total = total + 1
}
}
> x = total