Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

更新 #1187

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

更新 #1187

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
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"editor.detectIndentation": false,
"editor.tabSize": 4,
"editor.formatOnPaste": true,
"editor.formatOnSave": true
}
6 changes: 3 additions & 3 deletions Part.1.A.better.teachyourself.ipynb

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions Part.1.E.1.entrance.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,14 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"693 is odd.\n"
"375 is odd.\n"
]
}
],
Expand Down Expand Up @@ -858,8 +858,11 @@
}
],
"metadata": {
"interpreter": {
"hash": "7e1998ff7f8aa20ada591c520b972326324e5ea05489af9e422744c7c09f6dad"
},
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3.10.0 64-bit",
"language": "python",
"name": "python3"
},
Expand All @@ -873,7 +876,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.10.0"
},
"toc-autonumbering": true,
"toc-showmarkdowntxt": false
Expand Down
2 changes: 1 addition & 1 deletion Part.1.E.2.values-and-their-operators.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.10.0"
}
},
"nbformat": 4,
Expand Down
76 changes: 74 additions & 2 deletions Part.1.E.3.controlflow.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1784,6 +1784,75 @@
"> * 函数从控制流角度去看其实就是子程序"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 思考题\n",
"最后给你留一个思考题。\n",
"给定下面两个列表 attributes 和 values,要求针对 values 中每一组子列表 value,输出其和 attributes 中的键对应后的字典,最后返回字典组成的列表。\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'name': 'jason', 'dob': '2000-01-01', 'gender': 'male'},\n",
" {'name': 'mike', 'dob': '1999-01-01', 'gender': 'male'},\n",
" {'name': 'nancy', 'dob': '2001-02-01', 'gender': 'female'}]"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"attributes = ['name', 'dob', 'gender']\n",
"values = [['jason', '2000-01-01', 'male'], ['mike', '1999-01-01', 'male'],['nancy', '2001-02-01', 'female']]\n",
"# expected output:\n",
"result=[{'name': 'jason', 'dob': '2000-01-01', 'gender': 'male'}, {'name': 'mike', 'dob': '1999-01-01', 'gender': 'male'}, {'name': 'nancy', 'dob': '2001-02-01', 'gender': 'female'}]\n",
"#你能分别用一行和多行条件循环语句,来实现这个功能吗?\n",
"result"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'name': 'jason', 'dob': '2000-01-01', 'gender': 'male'},\n",
" {'name': 'mike', 'dob': '1999-01-01', 'gender': 'male'},\n",
" {'name': 'nancy', 'dob': '2001-02-01', 'gender': 'female'}]"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"attributes = ['name', 'dob', 'gender']\n",
"values = [['jason', '2000-01-01', 'male'], ['mike', '1999-01-01', 'male'],['nancy', '2001-02-01', 'female']]\n",
"list_a=[]\n",
"for i in range(len(values)):\n",
" dict_a={}\n",
" for j in range(len(attributes)):\n",
" dict_a[attributes[j]]=values[i][j]\n",
" # dict_a[attributes[1]]=values[0][1]\n",
" # dict_a[attributes[2]]=values[0][2]\n",
" list_a.append(dict_a)\n",
"# list_a.insert(1, attributes[0]+':'+values[0][0]) # 在索引 1 的位置插入 'example'\n",
"list_a"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -1793,8 +1862,11 @@
}
],
"metadata": {
"interpreter": {
"hash": "7e1998ff7f8aa20ada591c520b972326324e5ea05489af9e422744c7c09f6dad"
},
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3.10.0 64-bit",
"language": "python",
"name": "python3"
},
Expand All @@ -1808,7 +1880,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.10.0"
}
},
"nbformat": 4,
Expand Down
7 changes: 5 additions & 2 deletions Part.1.E.4.functions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,11 @@
}
],
"metadata": {
"interpreter": {
"hash": "21ee8af2579a8192c5b3880b850b5f93eed7daf2eb79d75b82c39de695db0d6e"
},
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3.9.7 ('base')",
"language": "python",
"name": "python3"
},
Expand All @@ -705,7 +708,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.9.16"
},
"toc-autonumbering": true
},
Expand Down
Loading