diff --git a/.gitignore b/.gitignore deleted file mode 100644 index a81c8ee121952cf06bfaf9ff9988edd8cded763c..0000000000000000000000000000000000000000 --- a/.gitignore +++ /dev/null @@ -1,138 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ diff --git a/202122011058.ipynb b/202122011108.ipynb similarity index 35% rename from 202122011058.ipynb rename to 202122011108.ipynb index 92397d6a369387d18ba9fc8992d0b21939a668a7..cad2b2d990b58cecdc4a21ee87410404e7bd91df 100644 --- a/202122011058.ipynb +++ b/202122011108.ipynb @@ -1,111 +1,60 @@ { "cells": [ - { - "cell_type": "markdown", - "id": "44b4398c", - "metadata": {}, - "source": [ - "# 作业要求以学号命名,类似\"123456.ipynb\",不需要加姓名。\n", - "\n", - "\n", - "作业提交的方式见下面链接:\n", - "https://blog.csdn.net/sheagu/article/details/122397816" - ] - }, - { - "cell_type": "markdown", - "id": "5d3dca5a", - "metadata": {}, - "source": [ - "## 题目一\n", - "\n", - "有一个这样的DNA核酸序列\n", - "\n", - "“AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC”\n", - "\n", - "请把这个核酸序列存入一个list,并数一数A、G、C、T各有多少个。" - ] - }, { "cell_type": "code", - "execution_count": 1, - "id": "e6521351", + "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "A有20个\n", - "G有17个\n", - "C有12个\n", - "T有21个\n" + "Count for A : 20\n", + "Count for T : 20\n", + "Count for C : 12\n", + "Count for G : 17\n" ] } ], "source": [ - "DNA = ['AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC']\n", - "A_num = 0\n", - "G_num = 0\n", - "C_num = 0\n", - "T_num = 0\n", - "for i in DNA[0]:\n", - " if i == 'A':\n", - " A_num += 1\n", - " elif i == 'G':\n", - " G_num += 1\n", - " elif i == 'C':\n", - " C_num += 1 \n", - " elif i == 'T':\n", - " T_num += 1\n", - "print(\"A有\" + str(A_num) + \"个\")\n", - "print(\"G有\" + str(G_num) + \"个\")\n", - "print(\"C有\" + str(C_num) + \"个\")\n", - "print(\"T有\" + str(T_num) + \"个\")\n", - "#以下为将DNA序列每个字母作为一个元素存入列表的情况\n", - "xulie = \"AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC\"\n", - "dna = []\n", - "for j in xulie:\n", - " dna.append(j)\n", - "a_num = 0\n", - "g_num = 0\n", - "c_num = 0\n", - "t_num = 0\n", - "for i in dna:\n", - " if i == 'A':\n", - " a_num += 1\n", - " elif i == 'G':\n", - " g_num += 1\n", - " elif i == 'C':\n", - " c_num += 1 \n", - " elif i == 'T':\n", - " t_num += 1" + "items = ['A','G','C','T','T','T,','T','C','A','T','T','C','T','G','A','C','T','G','C','A','A','C','G','G',\n", + " 'G','C','A','A','T','A','T','G','T','C','T','C','T','G','T','G','T','G','G','A','T','T','A',\n", + " 'A','A','A','A','A','A','G','A','G','T','G','T','C','T','G','A','T','A','G','C','A','G','C']\n", + "print (\"Count for A : \",items.count('A'))\n", + "print (\"Count for T : \",items.count('T'))\n", + "print (\"Count for C : \",items.count('C'))\n", + "print (\"Count for G : \",items.count('G'))" ] }, { - "cell_type": "markdown", - "id": "daf8500d", + "cell_type": "code", + "execution_count": 15, "metadata": {}, + "outputs": [ + { + "ename": "IndentationError", + "evalue": "unexpected indent (, line 5)", + "output_type": "error", + "traceback": [ + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m5\u001b[0m\n\u001b[0;31m scores.append(i)\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mIndentationError\u001b[0m\u001b[0;31m:\u001b[0m unexpected indent\n" + ] + } + ], "source": [ - "## 题目二\n", "\n", - "一个花样滑冰运动员表演后,裁判给表演内容进行评分,分数从0.25分到10分,每次增加值为0.25分。\n", - "\n", - "试生成一个元组,把可能的得分存入元组,并遍历元组的每一项,打印“一个运动员可能得_____分”。" + " " ] }, { "cell_type": "code", - "execution_count": 38, - "id": "90604ebb", + "execution_count": 29, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "(0.0, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 4.25, 4.5, 4.75, 5.0, 5.25, 5.5, 5.75, 6.0, 6.25, 6.5, 6.75, 7.0, 7.25, 7.5, 7.75, 8.0, 8.25, 8.5, 8.75, 9.0, 9.25, 9.5, 9.75, 10.0)\n", - "一个运动员可能得0.0分。\n", + "(0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 4.25, 4.5, 4.75, 5.0, 5.25, 5.5, 5.75, 6.0, 6.25, 6.5, 6.75, 7.0, 7.25, 7.5, 7.75, 8.0, 8.25, 8.5, 8.75, 9.0, 9.25, 9.5, 9.75, 10.0)\n", "一个运动员可能得0.25分。\n", "一个运动员可能得0.5分。\n", "一个运动员可能得0.75分。\n", @@ -151,94 +100,47 @@ ], "source": [ "score = ()\n", - "n = int(10/0.25 + 1)\n", + "n = int(10/0.25)\n", "for i in range(n):\n", - " score += (i*0.25,)\n", - " \n", + " score += ((i+1)*0.25,)\n", "print(score)\n", - "\n", + " \n", + " \n", "for j in score:\n", - " print(\"一个运动员可能得\" + str(j) + \"分。\")" - ] - }, - { - "cell_type": "markdown", - "id": "0c3a4e99", - "metadata": {}, - "source": [ - "## 题目三\n", - "\n", - "创建一个字典,列出你所了解的地域美食,比如{'肠粉':{'城市':'广州','原料':'米'}}。当然,你可以做的更丰富一些。\n", - "最后遍历你熟悉的美食,打印出,类似如下的句子:“肠粉是广州的一种美食,它的主要原料是米”。" + " if j != 0.0:\n", + " print(\"一个运动员可能得\" + str(j) + \"分。\")" ] }, { "cell_type": "code", - "execution_count": 52, - "id": "b0026af6", + "execution_count": 33, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "涮羊肉是北京的一种美食,它的主要原料是羊肉\n", - "巴克拉瓦(蜜饼)是西亚各国的一种美食,它的主要原料是酥皮、坚果\n", - "烤鸭是北京的一种美食,它的主要原料是鸭子\n", - "糖醋鲤鱼是济南的一种美食,它的主要原料是鲤鱼\n" + "臭豆腐是长沙的一种美食,它的主要原料是豆子\n", + "北京烤鸭是北京的一种美食,它的主要原料是鸭子\n", + "双皮奶是广州的一种美食,它的主要原料是奶\n" ] } ], "source": [ - "food = {'涮羊肉':{'城市':'北京','原料':'羊肉'},\n", - " '巴克拉瓦(蜜饼)':{'城市':'西亚各国','原料':'酥皮、坚果'},\n", - " '烤鸭':{'城市':'北京','原料':'鸭子'},\n", - " '糖醋鲤鱼':{'城市':'济南','原料':'鲤鱼'}\n", - " }\n", - "for key,value in food.items():\n", - " print(key + '是' + value['城市'] + '的一种美食,它的主要原料是' + value['原料'])" - ] - }, - { - "cell_type": "code", - "execution_count": 56, - "id": "4c3a6bc9", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "凯尔希是六星医疗干员。\n", - "阿米娅是五星术士/近卫干员。\n", - "史尔特尔是六星近卫干员。\n", - "浊心斯卡蒂是六星辅助干员。\n", - "风笛是六星先锋干员。\n", - "塞雷娅是六星重装干员。\n", - "能天使是六星狙击干员。\n", - "温蒂是六星特种干员。\n" - ] - } - ], - "source": [ - "##随便写了个别的\n", - "Users = {'凯尔希':{'星级':'六星','职介':'医疗'},\n", - " '阿米娅':{'星级':'五星','职介':'术士/近卫'},\n", - " '史尔特尔':{'星级':'六星','职介':'近卫'},\n", - " '浊心斯卡蒂':{'星级':'六星','职介':'辅助'},\n", - " '风笛':{'星级':'六星','职介':'先锋'},\n", - " '塞雷娅':{'星级':'六星','职介':'重装'},\n", - " '能天使':{'星级':'六星','职介':'狙击'},\n", - " '温蒂':{'星级':'六星','职介':'特种'}\n", + "foods = {'臭豆腐': {'城市': '长沙', '原料': '豆子'},\n", + " '北京烤鸭': {'城市': '北京', '原料': '鸭子'},\n", + " '双皮奶': {'城市': '广州', '原料': '奶'},\n", " }\n", - "for key,value in Users.items():\n", - " print(key + '是' + value['星级'] + value['职介'] + '干员。')" + "\n", + "\n", + "for key,value in foods.items():\n", + " print(key+'是'+value['城市']+'的一种美食,它的主要原料是'+value['原料'])\n", + " " ] }, { "cell_type": "code", "execution_count": null, - "id": "7c9bb8ac", "metadata": {}, "outputs": [], "source": [] @@ -246,7 +148,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -260,22 +162,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.0" - }, - "toc": { - "base_numbering": 1, - "nav_menu": {}, - "number_sections": false, - "sideBar": true, - "skip_h1_title": false, - "title_cell": "Table of Contents", - "title_sidebar": "Contents", - "toc_cell": false, - "toc_position": {}, - "toc_section_display": true, - "toc_window_display": false + "version": "3.7.6" } }, "nbformat": 4, - "nbformat_minor": 5 + "nbformat_minor": 4 }