diff --git a/README.md b/README.md index 4bd498a7a..217ca163b 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ 特别感谢**霍炬**([@virushuo](https://github.com/virushuo))、**洪强宁**([@hongqn](https://github.com/hongqn)) 两位良师诤友在此书写作过程中给予我的巨大帮助! +Runaway-bot 2025 年 2 月 14 日 + ```python # pseudo-code of selfteaching in Python diff --git a/my-notes/new/.idea/.gitignore b/my-notes/new/.idea/.gitignore new file mode 100644 index 000000000..26d33521a --- /dev/null +++ b/my-notes/new/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/my-notes/new/.idea/inspectionProfiles/Project_Default.xml b/my-notes/new/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 000000000..27d68537c --- /dev/null +++ b/my-notes/new/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/my-notes/new/.idea/inspectionProfiles/profiles_settings.xml b/my-notes/new/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 000000000..105ce2da2 --- /dev/null +++ b/my-notes/new/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/my-notes/new/.idea/misc.xml b/my-notes/new/.idea/misc.xml new file mode 100644 index 000000000..9d20c92d2 --- /dev/null +++ b/my-notes/new/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/my-notes/new/.idea/modules.xml b/my-notes/new/.idea/modules.xml new file mode 100644 index 000000000..960ca6e45 --- /dev/null +++ b/my-notes/new/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/my-notes/new/.idea/new.iml b/my-notes/new/.idea/new.iml new file mode 100644 index 000000000..d0876a78d --- /dev/null +++ b/my-notes/new/.idea/new.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/my-notes/new/Hello.py b/my-notes/new/Hello.py new file mode 100644 index 000000000..45f921519 --- /dev/null +++ b/my-notes/new/Hello.py @@ -0,0 +1 @@ +print('(True and False) yields:', True and False) \ No newline at end of file diff --git a/my-notes/new/Part1-E-1.ipynb b/my-notes/new/Part1-E-1.ipynb new file mode 100644 index 000000000..072555e27 --- /dev/null +++ b/my-notes/new/Part1-E-1.ipynb @@ -0,0 +1,294 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "c8ce66d9-f19e-41ed-97a2-8fc6217c98bf", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1\n", + "3\n", + "5\n", + "7\n", + "9\n" + ] + } + ], + "source": [ + "for i in range(10):\n", + " if i % 2 != 0:\n", + " print(i)" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "93a65062-eda2-42b6-b185-3a965fb859a1", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2\n", + "3\n", + "5\n", + "7\n", + "11\n", + "13\n", + "17\n", + "19\n", + "23\n", + "29\n", + "31\n", + "37\n", + "41\n", + "43\n", + "47\n", + "53\n", + "59\n", + "61\n", + "67\n", + "71\n", + "73\n", + "79\n", + "83\n", + "89\n", + "97\n" + ] + } + ], + "source": [ + "# 获取100以内的质数\n", + "\n", + "for n in range(2, 100):\n", + " if n == 2:\n", + " print(n)\n", + " continue\n", + " for i in range(2, n):\n", + " if (n % i) == 0:\n", + " break\n", + " else:\n", + " print(n)" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "473f1f9d-2148-4d7d-96a8-743802196147", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2\n", + "3\n", + "5\n", + "7\n", + "11\n", + "13\n", + "17\n", + "19\n", + "23\n", + "29\n", + "31\n", + "37\n", + "41\n", + "43\n", + "47\n", + "53\n", + "59\n", + "61\n", + "67\n", + "71\n", + "73\n", + "79\n", + "83\n", + "89\n", + "97\n" + ] + } + ], + "source": [ + "for n in range(2, 100):\n", + " if n == 2:\n", + " print(n)\n", + " continue\n", + " for i in range(2, int(n ** 0.5)+1):\n", + " if (n % i) == 0:\n", + " break\n", + " else:\n", + " print(n)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "5a5fdc10-d895-44dc-a79e-d726390d1438", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "3.1415926" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a = abs(-3.1415926)\n", + "a" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "3b1a9f45-c511-4989-95dc-0ac1b31ecd14", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "83\n", + "89\n", + "97\n", + "101\n", + "103\n", + "107\n", + "109\n" + ] + } + ], + "source": [ + "def is_prime(n):\n", + " if n < 2:\n", + " return False\n", + " if n == 2:\n", + " return True\n", + " for m in range(2, int(n ** 0.5)+1):\n", + " if (n % m) == 0:\n", + " return False\n", + " else:\n", + " return True\n", + "\n", + "for i in range(80, 110):\n", + " if is_prime(i):\n", + " print(i)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "808654fe-9e56-4663-8d99-9512abdbeb0b", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1\n" + ] + } + ], + "source": [ + "x = 0\n", + "x += 1\n", + "print(x)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "852917a5-c9f3-4a40-860c-1b9076d1f0e7", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "32b714dd-993e-4a8e-a5ad-efafd1cbf9ce", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "29119e58-515f-44ea-a086-2d4c72b9b558", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d4b2d537-3f9b-4306-92ed-234bf1dc1870", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f0d3417d-7ebe-4982-a9e3-dd4ff039b5ef", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "483fef03-e291-4668-b984-d99d4f70d192", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f74c48ae-8905-48e1-ad33-184560737020", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f9867a85-a207-4d60-9d33-489ecb39c294", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.12.4" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/my-notes/new/TrueandFalse.ipynb b/my-notes/new/TrueandFalse.ipynb new file mode 100644 index 000000000..6b962fe50 --- /dev/null +++ b/my-notes/new/TrueandFalse.ipynb @@ -0,0 +1,332 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "id": "8b2ee99e-1d72-448d-b6f2-aa5f7df040d0", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True and False) yields: False\n" + ] + } + ], + "source": [ + "print('True and False) yields:', True and False)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "98464ce4-86cd-4a66-a3cd-55fad21ddcd3", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(True and True) yields: True\n" + ] + } + ], + "source": [ + "print('(True and True) yields:', True and True)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "207f5419-7e34-4e68-8e6d-4cac0b8af224", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(False and True) yields: False\n" + ] + } + ], + "source": [ + "print('(False and True) yields:', False and True)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "31640f48-5c7e-4125-9c00-7e17c722d855", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(True or False) yields: True\n" + ] + } + ], + "source": [ + "print('(True or False) yields:', True or False)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "bc79d015-ea98-41c7-be8a-f65c17998d21", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(False or True) yields: True\n" + ] + } + ], + "source": [ + "print('(False or True) yields:', False or True)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "717c5a2b-2cce-4a01-90c0-d9309fc51e3b", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(False or False) yields: False\n" + ] + } + ], + "source": [ + "print('(False or False) yields:', False or False)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "8ffd1d98-dcb4-42a7-a2aa-4358461b0c5d", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(not True)yields: False\n" + ] + } + ], + "source": [ + "print('(not True)yields:', not True)" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "eb8c5b84-c11c-487b-b0bd-95ce68125c26", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(not False) yields: True\n" + ] + } + ], + "source": [ + "print('(not False) yields:', not False)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "7aef2283-81e0-47c3-91c6-bbb7c9727aeb", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n" + ] + } + ], + "source": [ + "print(not False)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9766b735-8d53-4bf2-a42b-0d9e7a786c92", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "f651242d-365c-4361-86b4-06fbcc87e052", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "19 is odd.\n" + ] + } + ], + "source": [ + "import random\n", + "\n", + "r = random.randrange(1, 100)\n", + "\n", + "if r % 2 == 0:\n", + " print(r, 'is even.')\n", + "else:\n", + " print(r, 'is odd.')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "59b37902-17d8-4fa4-ad28-1fa8c1b02532", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "c5fbcc70-9b69-48c5-85b9-60009f64050c", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1\n", + "3\n", + "5\n", + "7\n", + "9\n" + ] + } + ], + "source": [ + "for i in range(10):\n", + " if i % 2 != 0:\n", + " print(i)" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "id": "45ead3f8-0dfe-42d6-8b2d-60c46e3b25a5", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0\n", + "2\n", + "4\n", + "6\n", + "8\n" + ] + } + ], + "source": [ + "for i in range(10):\n", + " if i % 2 == 0:\n", + " print(i)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "642bf950-5da2-48aa-8494-97f06961eed3", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d9bc71ac-9756-4fb9-be33-7fa38f42a400", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "65ddc093-324a-41bb-8766-c5428499de8e", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2f1eca06-4a77-4eac-b054-d93a47adfca8", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "98a479eb-6018-420f-a131-e4cd202b01a5", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "922f5d58-4b8a-41af-94bc-c50310c3080c", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6a6e708c-f509-427d-8179-b9a9f9cdd354", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.12.4" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/my-notes/new/chat-test.py b/my-notes/new/chat-test.py new file mode 100644 index 000000000..7b267dc67 --- /dev/null +++ b/my-notes/new/chat-test.py @@ -0,0 +1,22 @@ +import os +from openai import OpenAI + +client = OpenAI( + # 请用知识引擎原子能力API Key将下行替换为:api_key="sk-xxx", + api_key="sk-yvpHpyv4AuIjgdHd6ZQDtJgUeLjtp96otQA2bntm5o8E1YWj", # 如何获取API Key:https://cloud.tencent.com/document/product/1772/115970 + base_url="https://api.lkeap.cloud.tencent.com/v1", +) + +completion = client.chat.completions.create( + model="deepseek-r1", # 此处以 deepseek-r1 为例,可按需更换模型名称。 + messages=[ + {'role': 'user', 'content': '9.9和9.11谁大'} + ] +) + +# 通过reasoning_content字段打印思考过程 +print("思考过程:") +print(completion.choices[0].message.reasoning_content) +# 通过content字段打印最终答案 +print("最终答案:") +print(completion.choices[0].message.content) \ No newline at end of file diff --git a/my-notes/new/hehe.py b/my-notes/new/hehe.py new file mode 100644 index 000000000..94e3a8723 --- /dev/null +++ b/my-notes/new/hehe.py @@ -0,0 +1,16 @@ +# This is a sample Python script. + +# Press ⌃R to execute it or replace it with your code. +# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings. + + +def print_hi(name): + # Use a breakpoint in the code line below to debug your script. + print(f'Hi, {name}') # Press ⌘F8 to toggle the breakpoint. + + +# Press the green button in the gutter to run the script. +if __name__ == '__main__': + print_hi('PyCharm') + +# See PyCharm help at https://www.jetbrains.com/help/pycharm/ diff --git a/my-notes/new/main.py b/my-notes/new/main.py new file mode 100644 index 000000000..94e3a8723 --- /dev/null +++ b/my-notes/new/main.py @@ -0,0 +1,16 @@ +# This is a sample Python script. + +# Press ⌃R to execute it or replace it with your code. +# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings. + + +def print_hi(name): + # Use a breakpoint in the code line below to debug your script. + print(f'Hi, {name}') # Press ⌘F8 to toggle the breakpoint. + + +# Press the green button in the gutter to run the script. +if __name__ == '__main__': + print_hi('PyCharm') + +# See PyCharm help at https://www.jetbrains.com/help/pycharm/ diff --git a/my-notes/new/test.py b/my-notes/new/test.py new file mode 100644 index 000000000..3bee2cd22 --- /dev/null +++ b/my-notes/new/test.py @@ -0,0 +1,4 @@ + +# 函数 +def add(a, b): + return a + b \ No newline at end of file