Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.ipynb_checkpoints/*
testfile.txt
testfile.txt
_output
.jupyterlite.doit.db
33 changes: 10 additions & 23 deletions Basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -514,22 +514,6 @@
"### _<ins>Example</ins>:_ Print type of a variable"
]
},
{
"cell_type": "markdown",
"id": "98edd5e0",
"metadata": {
"editable": false,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"source": [
"The `print` function which outputs text or variable values to the screen so they are visible while the program runs.\n",
"\n",
"This is one way to allow you to see what your program is doing as it executes."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -592,23 +576,26 @@
"tags": []
},
"source": [
"### _<ins>Example</ins>:_ Try to assign the data types at the following qr code"
"### _<ins>Quiz</ins>:_ For a given variable name: What type of data is stored in there?\n",
"Execute the cell to start the quiz"
]
},
{
"cell_type": "markdown",
"id": "8dc654b8",
"cell_type": "code",
"execution_count": null,
"id": "84c08047-1384-4734-9e44-81aea50035ed",
"metadata": {
"editable": false,
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"Try not to overthink. If something is ambiguous pick what fits best\n",
"\n",
"![QRCode](images/qr_question1.png)"
"%pip install jupyterquiz\n",
"from quizzes import display_quiz\n",
"display_quiz(\"quizzes/datatypes.json\")"
]
},
{
Expand Down
72 changes: 10 additions & 62 deletions Basics_filled.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -755,22 +755,6 @@
"### _<ins>Example</ins>:_ Print type of a variable"
]
},
{
"cell_type": "markdown",
"id": "98edd5e0",
"metadata": {
"editable": false,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"source": [
"The `print` function which outputs text or variable values to the screen so they are visible while the program runs.\n",
"\n",
"This is one way to allow you to see what your program is doing as it executes."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -871,62 +855,26 @@
"tags": []
},
"source": [
"### _<ins>Example</ins>:_ Try to assign the data types at the following qr code"
"### _<ins>Quiz</ins>:_ For a given variable name: What type of data is stored in there?\n",
"Execute the cell to start the quiz"
]
},
{
"cell_type": "markdown",
"id": "8dc654b8",
"cell_type": "code",
"execution_count": null,
"id": "84c08047-1384-4734-9e44-81aea50035ed",
"metadata": {
"editable": false,
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"Try not to overthink. If something is ambiguous pick what fits best\n",
"\n",
"![QRCode](images/qr_question1.png)"
]
},
{
"cell_type": "markdown",
"id": "6d81fa96",
"metadata": {
"editable": false,
"slideshow": {
"slide_type": "skip"
},
"tags": []
},
"source": [
"##### _<ins>Notes:</ins>_"
]
},
{
"cell_type": "markdown",
"id": "6fc5a2b1",
"metadata": {
"editable": false,
"slideshow": {
"slide_type": "skip"
},
"tags": []
},
"source": [
"Questions behind QR Code\n",
"Assign a type to the variable names\n",
"1. name\n",
" - str obviously\n",
"2. items_in_stock\n",
" - usually means a number -> int\n",
"3. pressure_bar\n",
" - if you have different physical units for a size put the unit into the name. Say you also have pressure_torr\n",
"4. is_student\n",
" - bool\n",
"5. participants\n",
" - is an ambiguous name (names, number, there are some) if this can happen, name the variable differently."
"%pip install jupyterquiz\n",
"from quizzes import display_quiz\n",
"display_quiz(\"quizzes/datatypes.json\")"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ dependencies:
- jupyter
- jupyterlab
- jupyterlab-deck
- jupyterquiz
- python
- jupyter_contrib_nbextensions
- jupytext
- jupyter_contrib_nbextensions
Binary file removed images/qr_question1.png
Binary file not shown.
18 changes: 18 additions & 0 deletions quizzes/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import jupyterquiz

def display_quiz(json_path):
colors = {
'--jq-multiple-choice-bg': '#66295B',
'--jq-mc-button-bg': '#fafafa',
'--jq-mc-button-border': '#66295B',
'--jq-many-choice-bg': '#66295B',
'--jq-numeric-bg': '#66295B',
'--jq-numeric-input-bg': '#fafafa',
'--jq-numeric-input-label': '#2d2d2d',
'--jq-numeric-input-shadow': '#4A1D42',
'--jq-string-bg': '#66295B',
'--jq-incorrect-color': '#c80202',
'--jq-correct-color': '#5CB85C',
'--jq-link-color': '#B8A7D6'
}
return jupyterquiz.display_quiz(json_path, border_radius=1, colors=colors)
132 changes: 132 additions & 0 deletions quizzes/datatypes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
[
{
"question": "Variable named <code>name</code>",
"type": "multiple_choice",
"answers": [
{
"answer": "str",
"correct": true,
"feedback": "Correct. A person's name is text data, so it should be a string."
},
{
"answer": "int",
"correct": false,
"feedback": "Numbers can't properly represent names."
},
{
"answer": "float",
"correct": false,
"feedback": "Names aren't decimal numbers."
},
{
"answer": "bool",
"correct": false,
"feedback": "A name isn't just True or False."
}
]
},
{
"question": "Variable named <code>num_items_in_stock</code>",
"type": "multiple_choice",
"answers": [
{
"answer": "int",
"correct": true,
"feedback": "Correct. Stock counts are whole numbers (integers). Usually you would not track 3.5 items in stock."
},
{
"answer": "str",
"correct": false,
"feedback": "While you could store it as text, numbers allow mathematical operations like adding or subtracting stock."
},
{
"answer": "float",
"correct": false,
"feedback": "Stock counts usually are whole numbers, not decimals."
},
{
"answer": "bool",
"correct": false,
"feedback": "The name implies a quantity, not just yes or no."
}
]
},
{
"question": "Variable named <code>height_m</code>",
"type": "multiple_choice",
"answers": [
{
"answer": "float",
"correct": true,
"feedback": "Correct. Height measurements typically have decimal precision (like 1.75m). The '_m' suffix indicates the unit (meters). If you also have <code>height_ft</code> or <code>height_cm</code>, putting the unit in the variable name keeps them distinct."
},
{
"answer": "str",
"correct": false,
"feedback": "You need to perform calculations with height values, like comparisons or conversions."
},
{
"answer": "int",
"correct": false,
"feedback": "While technically possible if you only need whole meters, measurements typically require decimal precision. Float is the conventional choice for physical measurements."
},
{
"answer": "bool",
"correct": false,
"feedback": "This represents a measurement value, not yes or no."
}
]
},
{
"question": "Variable named <code>is_student</code>",
"type": "multiple_choice",
"answers": [
{
"answer": "bool",
"correct": true,
"feedback": "Correct. The 'is_' prefix is a Python convention for boolean values. Someone either is or isn't a student."
},
{
"answer": "str",
"correct": false,
"feedback": "While you could use 'yes' or 'no' strings, bool is the Pythonic choice for true or false values."
},
{
"answer": "int",
"correct": false,
"feedback": "Don't use 0 and 1 for true and false - use bool instead."
},
{
"answer": "float",
"correct": false,
"feedback": "This is a yes or no question, not a number."
}
]
},
{
"question": "Variable named <code>participants</code><br><br><em>This variable name is ambiguous. Select all types that could be reasonable interpretations, then discuss: how would you rename this variable to be clearer?</em>",
"type": "many_choice",
"answers": [
{
"answer": "int",
"correct": true,
"feedback": "Yes, this could work if you're counting the number of participants. Better name: <code>participant_count</code> or <code>num_participants</code>."
},
{
"answer": "str",
"correct": true,
"feedback": "Yes, this could work if it's a text description like 'students and teachers'. Better name would depend on what you're describing - perhaps <code>participant_description</code>."
},
{
"answer": "float",
"correct": false,
"feedback": "This is unlikely - you can't have fractional participants. The main issue is that the variable name doesn't clearly communicate its purpose."
},
{
"answer": "bool",
"correct": false,
"feedback": "This doesn't fit - the name doesn't follow the 'is_' or 'has_' pattern typically used for booleans (like <code>has_participants</code>)."
}
]
}
]