diff --git a/src/epp_topics/python_basics/assignment_and_scalar_types/objectives_materials.ipynb b/src/epp_topics/python_basics/assignment_and_scalar_types/objectives_materials.ipynb index 6b12a61..a113a95 100644 --- a/src/epp_topics/python_basics/assignment_and_scalar_types/objectives_materials.ipynb +++ b/src/epp_topics/python_basics/assignment_and_scalar_types/objectives_materials.ipynb @@ -97,36 +97,35 @@ " },\n", " {\n", " \"question\": (\n", - " \"\"\"You want to convert a date that you stored as the following\n", - " string \"2021-01-01\" to a float object. Which of the following codes do\n", - " you think will do this (try on a notebook if you want)?\"\"\"\n", + " \"\"\"You want to convert a number that you stored as the following\n", + " string \"200,000.000\" to a float object corresponding to the number 200000.0.\n", + " Which of the following codes do you think will do this (try on a notebook if\n", + " you want)?\"\"\"\n", " ),\n", " \"type\": \"multiple_choice\",\n", " \"answers\": [\n", " {\n", - " \"answer\": 'float(\"2021-01-01\")',\n", - " \"correct\": False,\n", - " \"feedback\": \"Incorrect. The characters - cannot be handled by float().\",\n", + " \"answer\": 'float(\"200,000.000\".replace(\",\", \"\"))',\n", + " \"correct\": True,\n", + " \"feedback\": \"Correct.\",\n", " },\n", " {\n", - " \"answer\": \"float(2021-01-01)\",\n", + " \"answer\": 'float(\"200,000.000\")',\n", " \"correct\": False,\n", - " \"feedback\": \"\"\"Incorrect. Inputting 2021-01-01 without \\\" treats it\n", - " like a float, and floats cannot include special characters.\"\"\",\n", + " \"feedback\": \"\"\"Incorrect. This would yield a wrong result. Furthermore,\n", + " commas are not allowed in the float() function.\"\"\",\n", " },\n", " {\n", - " \"answer\": \"\"\"date = \\\"2021-01-01\\\".replace(\\\"-\\\", \\\".\\\") \\n\n", - " date = float(date)\"\"\",\n", - " \"correct\": True,\n", - " \"feedback\": \"\"\"Correct. Replace\n", - " remove all \\\" - \\\" characters to that the string can be handled\n", - " by float().\"\"\",\n", + " \"answer\": \"\"\"float(\"200,000.000\".replace(\".\", \"\"))\"\"\",\n", + " \"correct\": False,\n", + " \"feedback\": \"\"\"Incorrect. This would yield a wrong result.\n", + " Furthermore, commas are not allowed in the float() function.\"\"\",\n", " },\n", " {\n", - " \"answer\": \"This cannot be done.\",\n", + " \"answer\": 'float(\"200,000.000\".replace(\",\", \"\").replace(\".\", \"\"))',\n", " \"correct\": False,\n", - " \"feedback\": \"\"\"Incorrect. Not everything can be done, but when it is\n", - " about converting objects, tere is usually a quick way.\"\"\",\n", + " \"feedback\": \"\"\"Incorrect. This code will execute, but the resulting\n", + " float will be 200000000.0.\"\"\",\n", " },\n", " ],\n", " },\n", @@ -173,6 +172,7 @@ " ],\n", " },\n", "]\n", + "\n", "display_quiz(content, colors=\"fdsp\")" ] } diff --git a/src/epp_topics/scientific_computing/indexing/objectives_materials.ipynb b/src/epp_topics/scientific_computing/indexing/objectives_materials.ipynb index 4c90221..5eec5db 100644 --- a/src/epp_topics/scientific_computing/indexing/objectives_materials.ipynb +++ b/src/epp_topics/scientific_computing/indexing/objectives_materials.ipynb @@ -64,7 +64,7 @@ " \"List indexing is more flexible but array indexing is faster\": False,\n", " \"Array indexing generalizes to higher dimensions\": True,\n", " },\n", - " \"If you have a two dimensional array, then your_array(4) returns\": {\n", + " \"If you have a two dimensional array, then your_array[4] returns\": {\n", " \"An error message unless your array has 4 rows\": True,\n", " \"The forth column\": False,\n", " \"The forth element of the first row\": False,\n",