{"assignment":{"_schema_version":2,"course_id":37,"date_created":"2022-06-28T19:00:00+00:00","date_modified":"2022-07-12T14:55:23.286373+00:00","extra_instructor_files":"","extra_starting_files":"","forked_id":null,"forked_version":null,"hidden":false,"id":997,"instructions":"{\n  \"settings\": {\n    \"readingId\": \"bakery_functions_scopes_read\"\n  },\n  \"questions\": {\n    \"ScopeLifetime\": {\n      \"type\": \"true_false_question\",\n      \"points\": 1,\n      \"body\": \"The scope of a variable is how long the variable is \\\"alive\\\".\"\n    },\n    \"ScopeQuantity\": {\n      \"type\": \"multiple_choice_question\",\n      \"points\": 1,\n      \"body\": \"How many scopes are there in this program?\\n```python\\ndef make_message(value: int):\\n    return \\\"The result is\\\" + str(value)\\ndef modify_number(a_number: int) -> int:\\n    return a_number * 5 + 3\\nstart = 10\\nprint(make_message(modify_number(start)))\\n```\",\n      \"answers\": [\n        \"1 global scopes, 2 local scope\",\n        \"1 local scope, 2 global scopes\",\n        \"2 global scopes\",\n        \"6 global scopes\",\n        \"4 local scopes, 2 global scopes\",\n        \"4 local scopes, 1 global scope\"\n      ]\n    },\n    \"ScopeRulesOfThumb\": {\n      \"type\": \"multiple_answers_question\",\n      \"points\": 1,\n      \"body\": \"Mark each of the following that are good rules of thumb:\",\n      \"answers\": [\n        \"Variables inside a local scope should not be used outside that local scope.\",\n        \"Variables outside a local scope should not be used inside that local scope.\",\n        \"Variables inside a local scope should only be used outside that local scope.\",\n        \"Variables outside a local scope should only be used inside that local scope.\"\n      ]\n    },\n    \"ScopeIdentify\": {\n      \"type\": \"matching_question\",\n      \"points\": 3,\n      \"body\": \"Identify each variable as local to the function `calculate_price` or global:\\n```python\\ncoupon = 2.99\\ndef calculate_price(cost: float) -> float:\\n    tax = 1.1\\n    price = cost * tax - coupon\\n    return price\\noriginal_cost = 7.99\\nnew_price = calculate_price(original_cost)\\n```\",\n      \"answers\": [\n        \"global\",\n        \"local\"\n      ],\n      \"statements\": [\n        \"coupon\",\n        \"tax\",\n        \"cost\",\n        \"price\",\n        \"original_cost\",\n        \"new_price\"\n      ]\n    },\n    \"ScopeReturnVariable\": {\n      \"type\": \"true_false_question\",\n      \"points\": 1,\n      \"body\": \"Return can be used to return a variable so that variable is available outside a local scope.\"\n    },\n    \"ScopeCountUsage\": {\n      \"type\": \"short_answer_question\",\n      \"points\": 1,\n      \"body\": \"Consider this program:\\n```python\\n1 | x = 5\\n2 | def do_math(x: int) -> int:\\n3 |     return (x ** x + x)\\n4 | do_math(x)\\n```\\n\\nHow many times is the variable `x` defined on line 1 used (i.e. either read or written) in this program (including on\\nline 1)?\"\n    },\n    \"ScopeMutation\": {\n      \"type\": \"short_answer_question\",\n      \"points\": 1,\n      \"body\": \"Given the following code:\\n```python\\ny = 0\\ndef increase(y: int) -> int:\\n    y = y + 1\\n    return y\\nincrease(y)\\nincrease(y)\\nprint(y)\\n```\\n\\nWhat will be printed?\"\n    },\n    \"ScopeBadGlobals\": {\n      \"type\": \"multiple_choice_question\",\n      \"points\": 1,\n      \"body\": \"Why are global variables bad?\",\n      \"answers\": [\n        \"They make it harder to think about the program.\",\n        \"They \\\"leak\\\" memory so that data can escape the program.\",\n        \"Global variables are not bad.\",\n        \"They make the program slower.\"\n      ]\n    },\n    \"ParameterScopeGood\": {\n      \"type\": \"short_answer_question\",\n      \"points\": 1,\n      \"body\": \"What is printed after the code below is executed?\\n```python\\ndef add_half(a_variable: int) -> float:\\n    a_variable = a_variable+.5\\n    return a_variable\\n\\na = 1\\na = add_half(a)\\nprint(a)\\n```\"\n    },\n    \"ParameterScopeBad\": {\n      \"type\": \"short_answer_question\",\n      \"points\": 1,\n      \"body\": \"What is printed after the code below is executed?\\n```python\\ndef change_value(a_variable: int) -> int:\\n    a_variable = 5\\n    return a_variable\\n\\na = 7\\nchange_value(a)\\nprint(a)\\n```\"\n    }\n  }\n}","ip_ranges":"","name":"2B1) Scopes and Bodies","on_change":"","on_eval":"","on_run":"","owner_id":1,"owner_id__email":"acbart@udel.edu","points":1,"public":true,"reviewed":false,"sample_submissions":[],"settings":null,"starting_code":"","subordinate":false,"tags":[],"type":"quiz","url":"bakery_functions_scopes_quiz","version":1},"ip":"216.73.216.157","submission":{"_schema_version":3,"assignment_id":997,"assignment_version":1,"attempts":0,"code":"","correct":false,"course_id":37,"date_created":"2026-05-20T16:04:52.433479+00:00","date_due":"","date_graded":"","date_locked":"","date_modified":"2026-05-20T16:04:52.433479+00:00","date_started":"","date_submitted":"","endpoint":"","extra_files":"","feedback":"","grading_status":"NotReady","id":2037052,"score":0.0,"submission_status":"Started","time_limit":"","url":"submission_url-7a5f96fb-6725-4503-87ec-a2ed2920fbef","user_id":2044700,"user_id__email":"","version":0},"success":true}
