- 博客(19)
- 收藏
- 关注
原创 sklearn练习
练习内容:For this assignment you need to generate a random binary classificationproblem, and then train and test (using 10-fold cross validation) the threealgorithms. For some algorithms inner cross valid...
2018-06-16 23:15:20
315
原创 Jupyter notebook 练习
Anscombe's quartetIn [1]:%matplotlib inlineimport randomimport numpy as npimport scipy as spimport pandas as pdimport matplotlib.pyplot as pltimport seaborn as snsimport statsmodels.api as s...
2018-06-09 15:08:06
1153
原创 Scipy练习
Exercise 10.1: Least squaresGenerate matrix A ∈ R m×n with m > n. Also generate some vector b ∈ R m .Now find Print the norm of the residual.代码:import numpy as npfrom scipy.optimize import leastsq...
2018-06-03 11:47:21
340
原创 Matplotlib练习
Exercise 11.1: Plotting a functionPlot the functionover the interval [0,2]. Add proper axis labels, a title, etc.import numpy as npimport matplotlib.pyplot as pltxarr = np.linspace(0, 2, 1000)yarr...
2018-05-28 19:06:11
310
原创 NumPy练习
Generate matrices A, with random Gaussian entries, B, a Toeplitz matrix, where A ∈ R n×m and B ∈ R m×m ,for n = 200, m = 500.生成n×m矩阵A,其中各元素是服从高斯分布的随机数。生成常对角矩阵B。代码:import numpy as npimport scipy.linal...
2018-05-20 00:37:30
388
原创 Leetcode 832. Flipping an Image
题目原文:Given a binary matrix A, we want to flip the image horizontally, then invert it, and return the resulting image.To flip an image horizontally means that each row of the image is reversed. For ex...
2018-05-16 12:16:33
790
原创 Leetcode 461. Hamming Distance
题目原文:The Hamming distance between two integers is the number of positions at which the corresponding bits are different.Given two integers x and y, calculate the Hamming distance.Note:0 ≤ x, y < 23...
2018-05-01 23:12:13
179
原创 Leetcode 766. Toeplitz Matrix
题目原文:A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element.Now given an M x N matrix, return True if and only if the matrix is Toeplitz.判断一个矩阵在同一条从左上到右下的对角线中的值是否都相等...
2018-04-28 01:18:53
178
原创 Leetcode 66. Plus One
题目原文:Given a non-empty array of digits representing a non-negative integer, plus one to the integer.The digits are stored such that the most significant digit is at the head of the list, and each elem...
2018-04-28 01:07:29
150
原创 Python课本第十章课后习题选做
10-1 Python 学习笔记 :在文本编辑器中新建一个文件,写几句话来总结一下你至此学到的 Python 知识,其中每一行都以 “In Python you can” 打头。将这个文件命名为learning_python.txt ,并将其存储到为完成本章练习而编写的程序所在的目录中。编写一个程序,它读取这个文件,并将你所写的内容打印三次:第一次打印时读取整个文件;第二次打印时遍历文件对象;第三...
2018-03-30 20:48:22
579
原创 Python课本第九章课后习题选做
9-3 用户 :创建一个名为 User 的类,其中包含属性 first_name 和 last_name ,还有用户简介通常会存储的其他几个属性。在类 User 中定义一个名为 describe_user() 的方法,它打印用户信息摘要;再定义一个名为 greet_user() 的方法,它向用户发出个性化的问候。创建多个表示不同用户的实例,并对每个实例都调用上述两个方法。class User():...
2018-03-29 09:20:43
1987
原创 Python课本第八章课后习题选做
8-2 喜欢的图书 :编写一个名为 favorite_book() 的函数,其中包含一个名为 title 的形参。这个函数打印一条消息,如 One of my favorite books is Alice in Wonderland 。调用这个函数,并将一本图书的名称作为实参传递给它。def favorite_book( title ): print('One of my favorit...
2018-03-28 23:23:29
609
原创 Python课本第七章课后习题选做
7-1 汽车租赁 :编写一个程序,询问用户要租赁什么样的汽车,并打印一条消息,如 “Let me see if I can find you a Subaru” 。car = input('What car are you looking for: ')print('Let me see if I can find you a {}.'.format(car))What car are you ...
2018-03-28 22:17:16
1330
原创 Python课本第六章课后习题选做
6-1 人 :使用一个字典来存储一个熟人的信息,包括名、姓、年龄和居住的城市。该字典应包含键 first_name 、 last_name 、 age 和 city 。将存储在该字典中的每项信息都打印出来。my_friend = { 'first_name': 'cindy', 'second_name': 'candy', 'age': 17, 'city': '...
2018-03-28 21:50:37
1065
原创 Python课本第五章课后习题选做
5-2 更多的条件测试 :你并非只能创建 10 个测试。如果你想尝试做更多的比较,可再编写一些测试,并将它们加入到 conditional_tests.py 中。对于下面列出的各种测试,至少编写一个结果为 True 和 False 的测试。 a. 检查两个字符串相等和不等。 b. 使用函数 lower() 的测试。 c. 检查两个数字相等、不等、大于、小于、大于等于和小于等于。 ...
2018-03-24 13:07:43
3262
原创 Python课本第四章课后习题选做
4-2 动物 :想出至少三种有共同特征的动物,将这些动物的名称存储在一个列表中,再使用 for 循环将每种动物的名称都打印出来。 a. 修改这个程序,使其针对每种动物都打印一个句子,如 “A dog would make a great pet” 。 b. 在程序末尾添加一行代码,指出这些动物的共同之处,如打印诸如 “Any of these animals would...
2018-03-14 23:56:03
2773
原创 Python课本第三章课后习题选做
3-1 姓名: 将一些朋友的姓名存储在一个列表中,并将其命名为 names 。依次访问该列表中的每个元素,从而将每个朋友的姓名都打印出来。3-2 问候语: 继续使用练习 3-1 中的列表,但不打印每个朋友的姓名,而为每人打印一条消息。每条消息都包含相同的问候语,但抬头为相应朋友的姓名。>>> names = ['amami haruka', 'kisaragi chihaya',...
2018-03-12 23:36:44
2310
原创 Python课本第二章课后习题选做
2-2 多条简单消息: 将一条消息存储到变量中,将其打印出来;再将变量的值修改为一条新消息,并将其打印出来。>>> str = "I'm DD">>> print(str)I'm DD>>> str = "I'm not DD. DD is you.">>> print(str)I'm not
2018-03-11 13:42:22
1893
1
原创 初识python
今天,我第一次接触到Python。根据课本及老师的指导,成功地在Windows系统下搭建了Python环境,并运行第一个Python程序“Hello world!”。在Python官网上有很多对于Python学习有用的信息,对于目前的我来说,其中最有用的莫过于官方提供的文档,在文档页面,可以看到从入门者到高手,都提供有相应的文档用于参考,并且对于Python2和Python3都有丰富的资源,包括但...
2018-03-10 23:02:53
188
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅