From 6f7760c477810f1265e00c776633218f538d202f Mon Sep 17 00:00:00 2001 From: Jango <96159517+JangoCCC@users.noreply.github.com> Date: Sun, 12 May 2024 14:33:58 +0000 Subject: [PATCH] code: en lecture 0 and 10 ipynb code translation --- Languages/en/00_Set/Set.ipynb | 58 +++++++++++++++---------------- Languages/en/10_Euler/Euler.ipynb | 32 +++++------------ 2 files changed, 37 insertions(+), 53 deletions(-) diff --git a/Languages/en/00_Set/Set.ipynb b/Languages/en/00_Set/Set.ipynb index abdec4c..15736fa 100644 --- a/Languages/en/00_Set/Set.ipynb +++ b/Languages/en/00_Set/Set.ipynb @@ -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": [ { @@ -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)}')" ] }, { @@ -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", @@ -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)}')" ] }, { @@ -115,7 +115,7 @@ } ], "source": [ - "# 元组有序\n", + "# Tuples are ordered\n", "S = ('0xaa', 123, 'a', 0.123)\n", "for i in S:\n", " print(i)" @@ -123,51 +123,51 @@ }, { "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)" ] @@ -189,7 +189,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.5" + "version": "3.10.13" } }, "nbformat": 4, diff --git a/Languages/en/10_Euler/Euler.ipynb b/Languages/en/10_Euler/Euler.ipynb index c711d55..589b56a 100644 --- a/Languages/en/10_Euler/Euler.ipynb +++ b/Languages/en/10_Euler/Euler.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 30, + "execution_count": 1, "id": "0984cdd3", "metadata": {}, "outputs": [ @@ -10,8 +10,8 @@ "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" ] } ], @@ -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": { @@ -79,7 +63,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.7" + "version": "3.10.13" } }, "nbformat": 4,