// Numbas version: exam_results_page_options {"name": "Rounding numbers to a given number of decimal places", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Rounding numbers to a given number of decimal places", "type": "question", "tags": ["rounding", "taxonomy"], "variablesTest": {"condition": "", "maxRuns": "100"}, "variables": {"c1": {"templateType": "anything", "name": "c1", "description": "
Random number with 5 decimal places.
", "definition": "n_from_digits(cdig)*10^(-5) + random(1..5)", "group": "Ungrouped variables"}, "cdig": {"templateType": "anything", "name": "cdig", "description": "", "definition": "repeat(random(1..9), 5)", "group": "Ungrouped variables"}, "dp": {"templateType": "anything", "name": "dp", "description": "Number of decimal places to round.
", "definition": "random(3..4)", "group": "Ungrouped variables"}}, "extensions": [], "functions": {"n_from_digits": {"parameters": [["digits", "list"]], "type": "number", "language": "jme", "definition": "if(\n len(digits)=0,\n 0,\n digits[0]+10*n_from_digits(digits[1..len(digits)])\n)"}}, "statement": "We can approximate numbers by rounding.
\nRound $\\var{c1}$ to a given number of decimal places.
", "variable_groups": [], "parts": [{"scripts": {}, "variableReplacements": [], "marks": 0, "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "gaps": [{"correctAnswerFraction": false, "scripts": {}, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "allowFractions": false, "maxValue": "precround(c1, 1)", "showFeedbackIcon": true, "minValue": "precround(c1, 1)", "correctAnswerStyle": "plain", "mustBeReducedPC": 0, "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "marks": 1, "showCorrectAnswer": true}, {"correctAnswerFraction": false, "scripts": {}, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "allowFractions": false, "maxValue": "precround(c1, 2)", "showFeedbackIcon": true, "minValue": "precround(c1, 2)", "correctAnswerStyle": "plain", "mustBeReducedPC": 0, "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "marks": 1, "showCorrectAnswer": true}, {"correctAnswerFraction": false, "scripts": {}, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "allowFractions": false, "maxValue": "precround(c1, dp)", "showFeedbackIcon": true, "minValue": "precround(c1, dp)", "correctAnswerStyle": "plain", "mustBeReducedPC": 0, "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "marks": 1, "showCorrectAnswer": true}], "showCorrectAnswer": true, "prompt": "i) $\\var{c1}$ rounded to 1 decimal place is: [[0]]
\nii) $\\var{c1}$ rounded to 2 decimal places is: [[1]]
\niii) $\\var{c1}$ rounded to {dp} decimal places is: [[2]]
\n", "type": "gapfill"}], "ungrouped_variables": ["dp", "cdig", "c1"], "rulesets": {}, "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "Round numbers to a given number of decimal places.
"}, "preamble": {"css": "", "js": ""}, "advice": "The first thing to do when we are rounding numbers is to identify the last digit we are keeping.
\nWhen you're asked to round your answer to a number of decimal places, you need to decide whether to keep the last digit same (rounding down) or increase it by 1 (rounding up). If the following digit is less than 5 we round down and we round up when the next digit is 5 or more.
\nTo write it down in steps:
\nIt is important to keep in mind that if the digit we are increasing is 9, it becomes zero and we increase the previous digit instead. If this digit is 9 as well, we move along to the left side until we find a digit less than 9.
\nTo round a number to a given number $n$ of decimal places, we look at the $n$th digit after the decimal point.
\nWe have $\\var{c1}$.
\ni)
\nWe look at the first digit after the decimal point. This is $\\var{cdig[4]}$ and the following digit is $\\var{cdig[3]}$ so we round updown to get $\\var{precround(c1, 1)}$.
\nii)
\nThe second digit after the decimal point is $\\var{cdig[3]}$. It is followed by $\\var{cdig[2]}$ so we round updown to get $\\var{precround(c1, 2)}$.
\niii)
\nThe 3rd decimal place is $\\var{cdig[2]}$, followed by $\\var{cdig[1]}$. We get $\\var{precround(c1, 3)}$. The 4th decimal place is $\\var{cdig[1]}$, followed by $\\var{cdig[0]}$. We get $\\var{precround(c1, 4)}$.
\n", "contributors": [{"name": "Stanislav Duris", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1590/"}]}]}], "contributors": [{"name": "Stanislav Duris", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1590/"}]}