From fc37f361b5e137d0c04b6f8e9c8afbf03f498aa8 Mon Sep 17 00:00:00 2001 From: banshengtu <10693132+banshengtu@user.noreply.gitee.com> Date: Thu, 31 Mar 2022 12:36:34 +0000 Subject: [PATCH] =?UTF-8?q?=E5=8F=B6=E5=A9=B7+202122011160+=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E6=AC=A1=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 202122011160.ipynb | 285 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 285 insertions(+) create mode 100644 202122011160.ipynb diff --git a/202122011160.ipynb b/202122011160.ipynb new file mode 100644 index 0000000..fae304a --- /dev/null +++ b/202122011160.ipynb @@ -0,0 +1,285 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "5852d813", + "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": 95, + "id": "e6521351", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['A', 'G', 'C', 'T', 'T', 'T', 'T', 'C', 'A', 'T', 'T', 'C', 'T', 'G', 'A', 'C', 'T', 'G', 'C', 'A', 'A', 'C', 'G', 'G', 'G', 'C', 'A', 'A', 'T', 'A', 'T', 'G', 'T', 'C', 'T', 'C', 'T', 'G', 'T', 'G', 'T', 'G', 'G', 'A', 'T', 'T', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'G', 'A', 'G', 'T', 'G', 'T', 'C', 'T', 'G', 'A', 'T', 'A', 'G', 'C', 'A', 'G', 'C']\n", + "20\n", + "17\n", + "12\n", + "21\n" + ] + } + ], + "source": [ + "# 你的代码\n", + "\n", + "dna = ['A','G','C','T','T','T','T','C','A','T','T','C','T','G','A','C','T','G','C','A','A','C','G','G','G','C','A','A','T','A','T','G','T','C','T','C','T','G','T','G','T','G','G','A','T','T','A','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(dna) \n", + "\n", + "\n", + "a = [x for x in dna if x == 'A'] # 计算列表中A的个数\n", + "print(len(a))\n", + "\n", + "g = [x for x in dna if x == 'G'] # 计算列表中G的个数\n", + "print(len(g))\n", + "\n", + "c = [x for x in dna if x == 'C'] # 计算列表中C的个数\n", + "print(len(c))\n", + "\n", + "t = [x for x in dna if x == 'T'] # 计算列表中T的个数\n", + "print(len(t))" + ] + }, + { + "cell_type": "markdown", + "id": "daf8500d", + "metadata": {}, + "source": [ + "## 题目二\n", + "\n", + "一个花样滑冰运动员表演后,裁判给表演内容进行评分,分数从0.25分到10分,每次增加值为0.25分。\n", + "\n", + "试生成一个元组,把可能的得分存入元组,并遍历元组的每一项,打印“一个运动员可能得_____分”。" + ] + }, + { + "cell_type": "code", + "execution_count": 97, + "id": "90604ebb", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.25\n", + "0.5\n", + "0.75\n", + "1.0\n", + "1.25\n", + "1.5\n", + "1.75\n", + "2.0\n", + "2.25\n", + "2.5\n", + "2.75\n", + "3.0\n", + "3.25\n", + "3.5\n", + "3.75\n", + "4.0\n", + "4.25\n", + "4.5\n", + "4.75\n", + "5.0\n", + "5.25\n", + "5.5\n", + "5.75\n", + "6.0\n", + "6.25\n", + "6.5\n", + "6.75\n", + "7.0\n", + "7.25\n", + "7.5\n", + "7.75\n", + "8.0\n", + "8.25\n", + "8.5\n", + "8.75\n", + "9.0\n", + "9.25\n", + "9.5\n", + "9.75\n", + "10.0\n", + "一个运动员可能得0.25分\n", + "一个运动员可能得0.5分\n", + "一个运动员可能得0.75分\n", + "一个运动员可能得1.0分\n", + "一个运动员可能得1.25分\n", + "一个运动员可能得1.5分\n", + "一个运动员可能得1.75分\n", + "一个运动员可能得2.0分\n", + "一个运动员可能得2.25分\n", + "一个运动员可能得2.5分\n", + "一个运动员可能得2.75分\n", + "一个运动员可能得3.0分\n", + "一个运动员可能得3.25分\n", + "一个运动员可能得3.5分\n", + "一个运动员可能得3.75分\n", + "一个运动员可能得4.0分\n", + "一个运动员可能得4.25分\n", + "一个运动员可能得4.5分\n", + "一个运动员可能得4.75分\n", + "一个运动员可能得5.0分\n", + "一个运动员可能得5.25分\n", + "一个运动员可能得5.5分\n", + "一个运动员可能得5.75分\n", + "一个运动员可能得6.0分\n", + "一个运动员可能得6.25分\n", + "一个运动员可能得6.5分\n", + "一个运动员可能得6.75分\n", + "一个运动员可能得7.0分\n", + "一个运动员可能得7.25分\n", + "一个运动员可能得7.5分\n", + "一个运动员可能得7.75分\n", + "一个运动员可能得8.0分\n", + "一个运动员可能得8.25分\n", + "一个运动员可能得8.5分\n", + "一个运动员可能得8.75分\n", + "一个运动员可能得9.0分\n", + "一个运动员可能得9.25分\n", + "一个运动员可能得9.5分\n", + "一个运动员可能得9.75分\n", + "一个运动员可能得10.0分\n" + ] + } + ], + "source": [ + "# 你的代码\n", + "\n", + "a = 0.25\n", + "\n", + "# 输出可能的得分\n", + "while a <= 10:\n", + " print(a)\n", + " a = a + 0.25\n", + "\n", + "# 将可能的得分存入元组\n", + "scores = (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", + "\n", + "# 遍历元组的每一项,打印“一个运动员可能得_____分”\n", + "for b in scores:\n", + " score=str(b)\n", + " print(\"一个运动员可能得\" + score + \"分\")" + ] + }, + { + "cell_type": "markdown", + "id": "0c3a4e99", + "metadata": {}, + "source": [ + "## 题目三\n", + "\n", + "创建一个字典,列出你所了解的地域美食,比如{'肠粉':{'城市':'广州','原料':'米'}}。当然,你可以做的更丰富一些。\n", + "最后遍历你熟悉的美食,打印出,类似如下的句子:“肠粉是广州的一种美食,它的主要原料是米”。" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "b0026af6", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "肠粉是广州的一种美食,我个人觉得还行\n", + "\n", + "烤鸭是北京的一种美食,我个人觉得一般\n", + "\n", + "热干面是武汉的一种美食,我个人觉得不太好吃\n", + "\n", + "火锅是重庆的一种美食,我个人觉得很好吃\n", + "\n", + "茶颜悦色是湖南的一种美食,我个人觉得非常喜欢\n" + ] + } + ], + "source": [ + "# 你的代码\n", + "\n", + "# 创建字典\n", + "food = {'肠粉':{'城市':'广州','喜好':'还行'},\n", + " '烤鸭':{'城市':'北京','喜好':'一般'},\n", + " '热干面':{'城市':'武汉','喜好':'不太好吃'},\n", + " '火锅':{'城市':'重庆','喜好':'很好吃'},\n", + " '茶颜悦色':{'城市':'湖南','喜好':'非常喜欢'}}\n", + "\n", + "# 遍历美食\n", + "for foods_name, foods_information in food.items():\n", + " print(\"\\n%s是\" % foods_name + '%s的一种美食,'% foods_information['城市'] + '我个人觉得%s'% foods_information['喜好'])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4c3a6bc9", + "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.9.7" + }, + "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 + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} -- Gitee