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

doc: en lecture 0 and 10 ipynb code translation #84

Merged
merged 1 commit into from
May 12, 2024
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
58 changes: 29 additions & 29 deletions Languages/en/00_Set/Set.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
}
],
"source": [
"# 集合定义\n",
"# define set\n",
"S = {'0xaa', 123, 'a', 0.123}\n",
"# S = {2, 1, 1} \n",
"\n",
"\n",
"# 确定性, 互异性,无序性\n",
"# determinacy,distinctness and unorderedness\n",
"for elem in S:\n",
" print(elem)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -41,9 +41,9 @@
}
],
"source": [
"# 求基数\n",
"# calculate cardinality\n",
"S = {'0xaa', 123, 'a', 0.123}\n",
"print(f'集合S的基数为:{len(S)}')"
"print(f'the cardinality of set :{len(S)}')"
]
},
{
Expand All @@ -60,7 +60,7 @@
}
],
"source": [
"# 判断元素是否属于集合\n",
"# whether the element belongs to the set\n",
"S = {'0xaa', 123, 'a', 0.123}\n",
"if \"0xaa\" in S: \n",
" print(f'\"0xaa\" in S')\n",
Expand All @@ -70,32 +70,32 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"s1 s2 的差集为 {'0xaa', 1, 2}\n",
"s1 s2 的交集为 {3, 4}\n",
"s1 s2 的并集为 {1, 2, 3, 4, 5, 6, '0xaa', '0xbb'}\n"
"The set difference between s1 and s2 is {1, 2, '0xaa'}\n",
"The set intersection between s1 and s2 is {3, 4}\n",
"The set union between s1 and s2 is {1, 2, 3, 4, 5, 6, '0xaa', '0xbb'}\n"
]
}
],
"source": [
"# 集合之间的运算\n",
"# the operations between sets\n",
"s1 = {1, 2, 3, 4, \"0xaa\"}\n",
"s2 = {3, 4 ,5, 6, \"0xbb\"}\n",
"\n",
"## 求差集\n",
"print(f's1 s2 的差集为 {s1.difference(s2)}')\n",
"## Find the set difference\n",
"print(f'The set difference between s1 and s2 is {s1.difference(s2)}')\n",
"\n",
"## 求交集\n",
"print(f's1 s2 的交集为 {s1.intersection(s2)}')\n",
"## Find the set intersection\n",
"print(f'The set intersection between s1 and s2 is {s1.intersection(s2)}')\n",
"\n",
"## 求并集\n",
"print(f's1 s2 的并集为 {s1.union(s2)}')"
"## Find the set union\n",
"print(f'The set union between s1 and s2 is {s1.union(s2)}')"
]
},
{
Expand All @@ -115,59 +115,59 @@
}
],
"source": [
"# 元组有序\n",
"# Tuples are ordered\n",
"S = ('0xaa', 123, 'a', 0.123)\n",
"for i in S:\n",
" print(i)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"s1 和 s2 的笛卡尔积为:\n",
"The Cartesian product of s1 and s2 is:\n",
"(1, '0xbb')\n",
"(1, 3)\n",
"(1, 4)\n",
"(1, 5)\n",
"(1, 6)\n",
"(1, '0xbb')\n",
"(2, '0xbb')\n",
"(2, 3)\n",
"(2, 4)\n",
"(2, 5)\n",
"(2, 6)\n",
"(2, '0xbb')\n",
"(3, '0xbb')\n",
"(3, 3)\n",
"(3, 4)\n",
"(3, 5)\n",
"(3, 6)\n",
"(3, '0xbb')\n",
"(4, '0xbb')\n",
"(4, 3)\n",
"(4, 4)\n",
"(4, 5)\n",
"(4, 6)\n",
"(4, '0xbb')\n",
"('0xaa', '0xbb')\n",
"('0xaa', 3)\n",
"('0xaa', 4)\n",
"('0xaa', 5)\n",
"('0xaa', 6)\n",
"('0xaa', '0xbb')\n"
"('0xaa', 6)\n"
]
}
],
"source": [
"# 求笛卡尔积\n",
"# Find the Cartesian product\n",
"import itertools\n",
"\n",
"s1 = {1, 2, 3, 4, \"0xaa\"}\n",
"s2 = {3, 4 ,5, 6, \"0xbb\"}\n",
"\n",
"s = itertools.product(s1, s2)\n",
"print(f's1 s2 的笛卡尔积为:')\n",
"print(f'The Cartesian product of s1 and s2 is:')\n",
"for i in s:\n",
" print(i)"
]
Expand All @@ -189,7 +189,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.10.13"
}
},
"nbformat": 4,
Expand Down
32 changes: 8 additions & 24 deletions Languages/en/10_Euler/Euler.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
"cells": [
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 1,
"id": "0984cdd3",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"欧拉函数 phi(15): 8\n",
"欧拉定理: 7^phi(15) mod 15 = 1\n"
"Euler's totient function phi(15): 8\n",
"Euler's theorem: 7^phi(15) mod 15 = 1\n"
]
}
],
Expand All @@ -37,30 +37,14 @@
"\n",
"# 示例\n",
"n = 15\n",
"print(f\"欧拉函数 phi({n}): {euler_phi(n)}\")\n",
"# 欧拉函数 phi(15): 8\n",
"print(f\"Euler's totient function phi({n}): {euler_phi(n)}\")\n",
"# Euler's totient function phi(15): 8\n",
"\n",
"a = 7\n",
"result = euler_theorem(a, n)\n",
"print(f\"欧拉定理: {a}^phi({n}) mod {n} = {result}\")\n",
"# 欧拉定理: 7^phi(15) mod 15 = 1\n"
"print(f\"Euler's theorem: {a}^phi({n}) mod {n} = {result}\")\n",
"# Euler's theorem: 7^phi(15) mod 15 = 1\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dcf57645",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "80b58b91",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -79,7 +63,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.7"
"version": "3.10.13"
}
},
"nbformat": 4,
Expand Down