81 lines
1.8 KiB
Plaintext
81 lines
1.8 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# 1. `if-elif-else`\n",
|
|
"Fill `'TODO'` statements such that prints make sense."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"editable": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"name = 'John Doe'"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Modify 'TODO's\n",
|
|
"\n",
|
|
"if 'TODO':\n",
|
|
" print('Name \"{}\" is more than 20 chars long'.format(name))\n",
|
|
" length_description = 'long'\n",
|
|
"elif 'TODO':\n",
|
|
" print('Name \"{}\" is more than 15 chars long'.format(name))\n",
|
|
" length_description = 'semi long'\n",
|
|
"elif 'TODO':\n",
|
|
" print('Name \"{}\" is more than 10 chars long'.format(name))\n",
|
|
" length_description = 'semi long'\n",
|
|
"elif 'TODO':\n",
|
|
" print('Name \"{}\" is more than 8,9 or 10 chars long'.format(name))\n",
|
|
" length_description = 'semi short'\n",
|
|
"else:\n",
|
|
" print('Name \"{}\" is a short name'.format(name))\n",
|
|
" length_description = 'short'"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"editable": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"assert length_description == 'semi short'"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.5.4"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|