自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Python作业

王凯祺的Python作业

  • 博客(19)
  • 收藏
  • 关注

原创 第十五周作业

Assignment of SklearnTaskIn the second ML assignment you have to compare the performance of three different classification algorithms, namely Naive Bayes, SVM, and Random Forest.For this assig...

2018-06-19 19:24:15 327

原创 第十四周作业

今天老师讲了 pandas ,要求我们用 pandas 、numpy 等工具完成下面两项作业。%matplotlib inlineimport randomimport numpy as npimport scipy as spimport pandas as pdimport matplotlib.pyplot as pltimport seaborn as snsimp...

2018-06-12 17:40:08 190

原创 第十三周作业

今天老师讲了 Scipy 的用法,并要求我们做 Scipy 的课后练习。第一题随机生成一个 m×n(m>n)m×n(m>n)m \times n (m \gt n) 的矩阵 AAA 和一个 mmm 维向量 bbb ,求 x=argminx||Ax−b||2x=arg⁡minx||Ax−b||2x = \arg \min_x ||Ax - b|| _2这时候就可以用 ...

2018-06-04 17:07:30 251

原创 第十二周作业

今天老师介绍了 matplotlib ,并要求我们用 numpy 和 matplotlib 完成下面 3 题练习题:第一题画出 f(x)=sin2(x−2)e−x2f(x)=sin2(x−2)e−x2f(x) = sin^2(x - 2) e^{-x^2} 。参考老师给的课件,只要掌握了set_xlim, set_ylim, set_xlabel, set_ylabel, set_ti...

2018-05-28 17:52:00 205

原创 第十一周作业

Numpy这节课老师讲了 Numpy ,装个 Numpy 都能装半个钟 TAT ……查一查就知道有镜像源可以用啊 QAQ9.1 Matrix operationsCalculate A+A,AAT,ATAA+A,AAT,ATAA+A, AA^T, A^TA and ABABAB. Write a function that computes A(B−λI)A(B−λI)A(B-\lam...

2018-05-18 00:29:05 345

原创 第九周作业(周三)

第九周作业(周三)这节课老师讲了 Functional Programming ,我翻了几道题发现都用不着这个……Leetcode 124求二叉树上最大的路径和。这里注意路径至少有一个点。解法显然,树形dp。每个点维护两个值:这颗子树中最大的路径和 f(x)f(x)f(x)、从这个点往下走能走到的最大路径和 g(x)g(x)g(x) 。就有:f(x)=max(f(lson(x)...

2018-05-10 17:12:36 145

原创 第九周作业(周一)

第九周作业(周一)这周讲字符串,那就写一个字符串的题 #6 吧题目是按给定规则排列字符串,再按照给定规则输出。通过分析规律,容易找到新字符串的字符与旧字符串的字符的一对一的映射关系。class Solution: def convert(self, s, numRows): if numRows == 1: return s ...

2018-05-02 12:40:32 160

原创 第八周作业(周三)

Leetcode 题目再做一道 Array 的题目,#57标了Hard,发现好像不难。只要分三种情况讨论就好了,一是比newinterval.start小,二是比newinterval.end大,三是其他。class Solution: def insert(self, intervals, newInterval): ret = [] ok...

2018-05-02 11:06:00 130

原创 第八周作业(周一)

Leetcode Array林老师让我们在 Leetcode 找一道标签为 Array 的题目,用 Python 写。我随便找了一个 Hard 的来看看。我找了题目 #84 ,题目链接 https://leetcode.com/problems/largest-rectangle-in-histogram/description/ 。题意是说,给定 a1,a2,⋯ana1,a2,⋯an...

2018-04-23 21:44:21 233

原创 第五周作业(周三)

第10章作业习题10-1learning_python.txtIn Python you can workIn Python you can sleepIn Python you can be lazya.pyfilename = 'learning_python.txt'with open(filename) as f: contents = f.re...

2018-04-09 00:29:14 124

原创 第五周作业(周一)

第9章作业习题9-1class Restaurant(): def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type def describe_r...

2018-04-09 00:16:07 236

原创 第四周作业(周三)

第8章作业习题8-2def favorite_book(title): print("My favorite book is " + title)favorite_book("Alice in Wonderland")My favorite book is Alice in Wonderland习题8-4def make_shirt(sent...

2018-03-29 16:13:46 165

原创 第四周作业(周一)

第7章作业习题7-1car = input("What car do you want: ")print("Let me see if I can find you a " + car)What car do you want: YanBinLet me see if I can find you a YanBin习题7-3n = input("Inpu...

2018-03-29 13:47:42 148

原创 第三周作业(周三)

第6章作业习题6-1>>> person = {'first_name':'Alice', 'last_name': 'Bob', 'age':18, 'city':'Guangzhou'}>>> person{'first_name': 'Alice', 'last_name': 'Bob', 'age': 18, 'city': 'Guang...

2018-03-24 23:01:32 138

原创 第三周作业(周一)

第5章作业习题5-4>>> alien_color = 'green'>>> if alien_color == 'green':... print('score 5 points')... else:... print('score 10 points')... score 5 points>>>...

2018-03-19 11:22:29 179

原创 第二周作业(周三)

第二周作业习题4-1>>> pizza = ['liulian', 'haixian', 'zhishi']>>> for i in pizza:... print('i like ' + i + ' pizza')... i like liulian pizzai like haixian pizzai like zhish...

2018-03-15 20:02:26 190 1

原创 第二周作业(周一)

第3章作业习题3-1>>> names = ['Wang JP', 'Wang QC', 'Wang ZS']>>> for i in names:... print(i)... Wang JPWang QCWang ZS本题只要熟悉list的用法即可做出。习题3-2>>> for i in na...

2018-03-12 22:26:24 180

原创 第一周作业(周三)

第2章作业习题 2-1mSg = "message"print(mSg)print(msg)结果如下:messageTraceback (most recent call last): File "<stdin>", line 1, in <module>NameError: name 'msg' is not defined我们可以...

2018-03-08 14:46:25 188

原创 第一周作业(周一)

第一周作业浏览Python主页的发现和收获Python的入门教程非常完善,包括下载、安装的文档,以及Python语法、用法的文档,还有FAQ。Python的文档内容丰富,包括了Python的数据类型、控制语句、以及字符串处理等内容。在每一节,除了有语句的详细解释,更有范例帮助新手理解这些语法。Python的文档还介绍了代码风格。它建议使用4个空格作为一个缩进,而不选用Tab作为缩...

2018-03-05 11:02:12 166

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除