Skip to content

Commit

Permalink
Fix question in quiz for variable assignment, fixes #43 (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcofo21 authored Nov 28, 2024
1 parent bb7e68a commit 460f1f9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -173,6 +172,7 @@
" ],\n",
" },\n",
"]\n",
"\n",
"display_quiz(content, colors=\"fdsp\")"
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 460f1f9

Please sign in to comment.