
作业
linearyx
这个作者很懒,什么都没留下…
展开
-
Python 第三章部分练习
3-1姓名:将一些朋友的姓名存储在一个列表中,并将其命名为names。依次访问该列表中的每个元素,从而将每个朋友的姓名都打印出来。3-2问候语:3-4 嘉宾名单:3-5 修改嘉宾名单:3-6 添加嘉宾3-9 晚餐嘉宾...原创 2018-03-12 17:19:43 · 464 阅读 · 0 评论 -
Scipy 练习
这道题要求使用最小二乘法找到这个x并且输出残差的范数,程序如下:import scipyfrom scipy import linalgfrom scipy.optimize import leastsqA = scipy.random.normal(size=[30, 20])b = scipy.random.normal(size=[30])def error(x, A, b)...原创 2018-06-04 23:52:22 · 605 阅读 · 0 评论 -
Jupyter 练习
anscombe里有四个datasetpart1要求算出四个dataset的x、y均值、算出四个dataset的x、y的相关系数、实现线性回归import randomimport numpy as npimport scipy as spimport pandas as pdimport matplotlib.pyplot as pltimport seaborn as snsi...原创 2018-06-11 22:27:40 · 552 阅读 · 0 评论 -
Matplotlib 练习
import matplotlib.pyplot as pltfrom pylab import *import numpyfrom scipy.stats import gaussian_kde#exercise 1x = np.linspace(0, 2)y = np.power(np.sin(x-2), 2)*np.power(np.e, -x*x)plt.plot(x, y...原创 2018-05-27 19:54:16 · 319 阅读 · 1 评论 -
Leetcode题解 4. Median of Two Sorted Arrays 【Array】
题目:There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).Example 1:nums1 = [1, 3]nu...原创 2018-04-29 12:08:36 · 274 阅读 · 0 评论 -
Numpy 练习
先设置随机数种子:import numpy as npimport timeseed = np.int64(time.time())print(seed)np.random.seed(seed)Generate matrices A, with random Gaussian entries, B, a Toeplitz matrix, where A ∈Rn×m and B ∈Rm×m,...原创 2018-05-19 11:47:17 · 433 阅读 · 0 评论 -
Leetcode题解 23. Merge k Sorted Lists【Linked List】
题目:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Example:Input:[ 1->4->5, 1->3->4, 2->6]Output: 1->1->2->3->4-&g...原创 2018-04-26 22:27:51 · 119 阅读 · 0 评论 -
Leetcode题解 813 Largest Sum of Averages 【Dynamic programming】
813. Largest Sum of AveragesWe partition a row of numbers A into at most K adjacent (non-empty) groups, then our score is the sum of the average of each group. What is the largest score we can achieve...原创 2018-05-04 01:02:21 · 237 阅读 · 0 评论 -
Leetcode题解 495.Teemo Attacking 【Array】
In LOL world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Teemo's attacking ascending time series towards Ashe and the poisoning tim...原创 2018-04-23 20:18:13 · 150 阅读 · 0 评论 -
Python第十章部分习题
10-1 Python学习笔记代码:filename = r'D:\homework.txt'with open(filename) as file_object: contents = file_object.read() print(contents)with open(filename) as file_object: for line in file_obj...原创 2018-04-05 14:20:43 · 353 阅读 · 0 评论 -
Python 第八章部分习题
8-1 消息代码:def display_message(): print("I learn how to write a function") def main(): display_message() if __name__ == '__main__': main()输出:8-2 喜欢的图书代码:def favorite_book(book_name): p...原创 2018-03-29 00:46:56 · 832 阅读 · 0 评论 -
Python 第七章部分练习
7.1 汽车租赁代码:car = input("Hello ,please tell which car you want to lease\n car name:")print("Let me see if I can find you a " + car)输出(输入为Subarn):7-2 餐馆订位代码:num = input("Hello ,please tell me how many ...原创 2018-03-28 00:36:40 · 1656 阅读 · 0 评论 -
Python第九章部分习题
9-1 餐馆代码:class restaurant: def __init__(self, name, ctype): self.restaurant_name = name self.cuisine_type = ctype def discribe_restaurant(self): print("Restaurant ...原创 2018-04-02 19:17:34 · 335 阅读 · 0 评论 -
Python 第十一章部分习题
11-1 城市和国家:代码:homework.pydef city_fun(city, country): return city.title()+", "+countrytest_cities.pyimport unittestfrom homework import city_funclass CityTestCase(unittest.TestCase): def te...原创 2018-04-10 01:17:17 · 518 阅读 · 0 评论 -
Python第六章部分习题
6-1 人输出:6-2喜欢的数字:输出:6-10 喜欢的数字#2输出:原创 2018-03-22 00:11:06 · 392 阅读 · 0 评论 -
sklearn练习
这个练习是让我们比较三种分类算法的性能,加上学习调试一些算法的参数。详情请看注释:代码中没有from sklearn import cross_validation,因为pycharm提示这个库在新版上sklearn已经被删掉了from sklearn import datasetsfrom sklearn.model_selection import KFoldfrom sklearn.na...原创 2018-06-16 20:24:54 · 374 阅读 · 0 评论