Skip to content

Commit

Permalink
add exercise
Browse files Browse the repository at this point in the history
  • Loading branch information
d-chambers committed Jan 20, 2024
1 parent a6e5b0d commit 3830551
Showing 1 changed file with 44 additions and 5 deletions.
49 changes: 44 additions & 5 deletions content/data_types.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"source": [
"# Datatypes exercise \n",
"Follow the instructions in the following cells. If the test cells run without issues your code is good to go. "
"Complete the code in the cells without the `#TESTS` comment. If the corresponding tests block runs, move on to the next exercise. "
],
"metadata": {
"collapsed": false
Expand All @@ -15,9 +15,8 @@
"cell_type": "code",
"outputs": [],
"source": [
"# Complete the following function \n",
"def func(): \n",
" pass"
"# Populate the list with five integers\n",
"my_list = []"
],
"metadata": {
"collapsed": true,
Expand All @@ -29,11 +28,51 @@
{
"cell_type": "code",
"outputs": [],
"source": [],
"source": [
"# TESTS\n",
"assert len(my_list) == 5\n",
"assert all([isinstance(x, int) for x in my_list])"
],
"metadata": {
"collapsed": false
},
"id": "a3391f06e70a65b2"
},
{
"cell_type": "markdown",
"source": [],
"metadata": {
"collapsed": false
},
"id": "f1f3546706e45076"
},
{
"cell_type": "code",
"outputs": [],
"source": [
"# Create dictionary with string keys and int values from 1 to 3\n",
"my_dict = {}"
],
"metadata": {
"collapsed": false
},
"id": "ab3c7d41ed645357"
},
{
"cell_type": "code",
"outputs": [],
"source": [
"# TESTS\n",
"assert len(my_dict) == 3\n",
"for val in range(1, 4):\n",
" expected_key = str(val)\n",
" assert expected_key in my_dict\n",
" assert my_dict[expected_key] == val"
],
"metadata": {
"collapsed": false
},
"id": "55c00b8e5fecaf45"
}
],
"metadata": {
Expand Down

0 comments on commit 3830551

Please sign in to comment.