{"assignment":{"_schema_version":2,"course_id":37,"date_created":"2022-06-28T19:00:00+00:00","date_modified":"2024-10-18T16:04:50.409197+00:00","extra_instructor_files":"","extra_starting_files":"","forked_id":null,"forked_version":null,"hidden":false,"id":1118,"instructions":"{\n  \"settings\": {\n    \"readingId\": \"bakery_nesting_heavy_read\"\n  },\n  \"questions\": {\n    \"PythonTypes\": {\n      \"type\": \"matching_question\",\n      \"points\": 6,\n      \"body\": \"Label each of the following as a \\\"Primitive type\\\", \\\"Composite type\\\", or \\\"Not a type\\\":\",\n      \"answers\": [\n        \"Primitive type\",\n        \"Composite type\",\n        \"Not a type\"\n      ],\n      \"retainOrder\": true,\n      \"statements\": [\n        \"Boolean\",\n        \"String\",\n        \"List\",\n        \"Attribute\",\n        \"Types created as dataclasses\",\n        \"Value\",\n        \"Integer\",\n        \"Float\",\n        \"None\",\n        \"Return\",\n        \"For\",\n        \"Literal\"\n      ]\n    },\n    \"ListsOfDictionaries\": {\n      \"type\": \"true_false_question\",\n      \"points\": 1,\n      \"body\": \"Lists can be composed of instances of dataclasses.\"\n    },\n    \"DictionariesOfLists\": {\n      \"type\": \"true_false_question\",\n      \"points\": 1,\n      \"body\": \"Dataclass instances can have lists.\"\n    },\n    \"StringsOfLists\": {\n      \"type\": \"true_false_question\",\n      \"points\": 1,\n      \"body\": \"Strings can be composed of Lists.\"\n    },\n    \"ListOfList\": {\n      \"type\": \"multiple_choice_question\",\n      \"points\": 1,\n      \"body\": \"What is the type of the following expression?\\n\\n[[0]]\",\n      \"answers\": [\n        \"List of List of Integers\",\n        \"List of Integers\",\n        \"Integer\",\n        \"Not a valid expression\"\n      ]\n    },\n    \"LengthOfLOD\": {\n      \"type\": \"multiple_choice_question\",\n      \"points\": 1,\n      \"body\": \"How many elements are in the following list?\\n\\n```python\\nfrom dataclasses import dataclass\\n\\n@dataclass\\nclass Activity:\\n    name: str\\n    high_energy: bool\\n\\n@dataclass\\nclass Animal:\\n    name: str\\n    age: int\\n    hobby: Activity\\n    type: str\\n\\nanimals = [\\n    Animal(\\\"Ada\\\", 4, Activity(\\\"Fetch\\\", True), \\\"dog\\\"),\\n    Animal(\\\"Babbage\\\", 5, Activity(\\\"Napping\\\", True), \\\"dog\\\"),\\n    Animal(\\\"Captain\\\", 1, Activity(\\\"Destruction\\\", True), \\\"cat\\\")\\n]\\n```\",\n      \"answers\": [\n        \"0\",\n        \"3\",\n        \"4\",\n        \"12\",\n        \"15\"\n      ]\n    },\n    \"ComplexExpressions\": {\n      \"type\": \"matching_question\",\n      \"points\": 5,\n      \"body\": \"Given the following code:\\n\\n```python\\nfrom dataclasses import dataclass\\n\\n@dataclass\\nclass Movie:\\n    name: str\\n    length: int\\n    cast: list[str]\\n\\nmovies = [\\n    Movie(\\\"Jurassic Park\\\", 127, [\\\"Goldblum\\\", \\\"Neill\\\", \\\"Dern\\\"]),\\n    Movie(\\\"Castle in the Sky\\\", 140, [\\\"Paquin\\\", \\\"Beek\\\", \\\"Leachman\\\"]),\\n    Movie(\\\"It\\\", 135, [\\\"Curry\\\", \\\"Green\\\", \\\"Brandis\\\"])\\n]\\n```\\n\\nWhat is the value of the following expressions?\",\n      \"retainOrder\": true,\n      \"answers\": [\n        \"Raises an error\",\n        \"\\\"Jurassic Park\\\"\",\n        \"\\\"Castle in the Sky\\\"\",\n        \"\\\"It\\\"\",\n        \"\\\"Curry\\\"\",\n        \"\\\"Goldblum\\\"\",\n        \"\\\"Leachman\\\"\",\n        \"135\",\n        \"0\"\n      ],\n      \"statements\": [\n        \"movies[0].name\",\n        \"movies[2].name\",\n        \"movies[0][127]\",\n        \"movies[1][1]\",\n        \"movies[127].name\",\n        \"movies[2].cast[0]\",\n        \"movies[2].cast.Curry\",\n        \"movies[1].cast[2]\",\n        \"movies[2].Curry\",\n        \"movies[-1].length\"\n      ]\n    },\n    \"BigMovieExample\": {\n      \"type\": \"text_only_question\",\n      \"points\": 0,\n      \"body\": \"The next few questions will all use the same code:\\n\\n```python\\nfrom dataclasses import dataclass\\n\\n@dataclass\\nclass Profit:\\n    # In millions\\n    costs: int\\n    revenue: int\\n\\n@dataclass\\nclass Movie:\\n    name: str\\n    length: int\\n    profit: Profit\\n    cast: list[str]\\n    \\n@dataclass\\nclass Theater:\\n    name: str\\n    is_open: bool\\n    showing: list[Movie]\\n\\ntheaters = [\\n    Theater(\\\"Main Street Theater\\\", True, [\\n        Movie(\\\"Jurassic Park\\\", 127, Profit(63, 1046),\\n            [\\\"Goldblum\\\", \\\"Neill\\\", \\\"Dern\\\"]),\\n        Movie(\\\"Castle in the Sky\\\", 140, Profit(3, 16),\\n            [\\\"Paquin\\\", \\\"Beek\\\", \\\"Leachman\\\"]),\\n        Movie(\\\"The Notebook\\\", 121, Profit(29, 118),\\n            [\\\"McAdams\\\", \\\"Gosling\\\", \\\"Rowlands\\\"])\\n    ]),\\n    Theater(\\\"BlockBuster Cinema\\\", False, [\\n        Movie(\\\"Cats\\\", 110, Profit(100, 75),\\n            [\\\"Dench\\\", \\\"Corden\\\", \\\"Derulo\\\"]),\\n        Movie(\\\"Morbius\\\", 104, Profit(86, 45),\\n            [\\\"Leto\\\", \\\"Smith\\\", \\\"Arjona\\\"])\\n    ]),\\n    Theater(\\\"All Star Movies\\\", True, [\\n        Movie(\\\"Gone with the Wind\\\", 221, Profit(4, 390),\\n            [\\\"Leigh\\\", \\\"Gable\\\", \\\"Havilland\\\"])\\n    ])\\n]\\n```\\n\\nA diagram is also provided to help you understand the data and its relationships.\\n\\n![A class diagram for the Theater, Movie, and Profit relationships](https://i.imgur.com/cQTtat7.png)\"\n    },\n    \"Evaluate Heavily Nested Types\": {\n      \"type\": \"matching_question\",\n      \"points\": 4,\n      \"body\": \"Given the code above and the code below:\\n\\n```python\\nalpha = 0\\nfor theater in theaters:\\n    for movie in theater.showing:\\n        alpha += movie.profit.costs\\n```\\n\\nInside of the loop body, what are the most accurate types of the following expressions:\",\n      \"retainOrder\": true,\n      \"answers\": [\n        \"Theater\",\n        \"list[Theater]\",\n        \"Movie\",\n        \"list[Movie]\",\n        \"Profit\",\n        \"list[Profit]\",\n        \"int\",\n        \"str\",\n        \"bool\",\n        \"An error occurs\"\n      ],\n      \"statements\": [\n        \"theater\",\n        \"theater.name\",\n        \"theater.length\",\n        \"theater.showing\",\n        \"movie\",\n        \"movie.name\",\n        \"movie.length\",\n        \"movie.profit\",\n        \"movie.profit.costs\",\n        \"alpha\"\n      ]\n    },\n    \"Evaluate Nested Find Example\": {\n      \"type\": \"short_answer_question\",\n      \"points\": 1,\n      \"body\": \"Given the following function:\\n\\n```python\\ndef alpha(theaters: list[Theater]) -> str:\\n    for theater in theaters:\\n        for movie in theater.showing:\\n            potential = beta(movie)\\n            if potential < 0:\\n                return movie.name\\n    return None\\n    \\ndef beta(movie: Movie) -> int:\\n    profit = movie.profit\\n    return profit.revenue - profit.costs\\n```\\n\\nWhat will the expression `print(alpha(theaters))` output?\"\n    },\n    \"Evaluate Nested Filter Max\": {\n      \"type\": \"short_answer_question\",\n      \"points\": 1,\n      \"body\": \"Given the following function:\\n\\n```python\\ndef unknown(theaters: list[Theater]) -> str:\\n    theaters = step1(theaters)\\n    if not theaters:\\n        return \\\"No results\\\"\\n    result = step2(theaters)\\n    return result.name\\n\\ndef step1(theaters: list[Theater]) -> list[Theater]:\\n    result = []\\n    for theater in theaters:\\n        if theater.is_open:\\n            result.append(theater)\\n    return result\\n    \\ndef step2(theaters: list[Theater]) -> Theater:\\n    result = theaters[0]\\n    result_length = theaters[0].showing[0].length\\n    for theater in theaters:\\n        for movie in theater.showing:\\n            if result_length > movie.length:\\n                result = theater\\n                result_length = movie.length\\n    return result\\n```\\n\\nWhat will the expression `print(unknown(theaters))` output?\"\n    }\n  }\n}","ip_ranges":"","name":"8B2) Heavily Nested Data","on_change":"","on_eval":"","on_run":"","owner_id":1,"owner_id__email":"acbart@udel.edu","points":1,"public":true,"reviewed":false,"sample_submissions":[],"settings":"","starting_code":"","subordinate":false,"tags":[],"type":"quiz","url":"bakery_nesting_heavy_quiz","version":2},"ip":"216.73.216.157","submission":{"_schema_version":3,"assignment_id":1118,"assignment_version":2,"attempts":0,"code":"","correct":false,"course_id":37,"date_created":"2026-05-20T14:01:37.715568+00:00","date_due":"","date_graded":"","date_locked":"","date_modified":"2026-05-20T14:01:37.715568+00:00","date_started":"","date_submitted":"","endpoint":"","extra_files":"","feedback":"","grading_status":"NotReady","id":2036893,"score":0.0,"submission_status":"Started","time_limit":"","url":"submission_url-61dd9fc0-ebbf-405f-ac2f-4add0d140b9c","user_id":2044668,"user_id__email":"","version":0},"success":true}
