- 博客(20)
- 资源 (1)
- 收藏
- 关注
原创 2018.6.13 python作业:sklearn exercise
作业:In the second ML assignment you have to compare the performance of three di↵erent classification algorithms, namely Naive Bayes, SVM, and Random Forest. For this assignment you need to generate a ra...
2018-06-18 23:42:31 188
原创 2018.6.6 python作业:jupyter exercise
Anscombe's quartetAnscombe's quartet comprises of four datasets, and is rather famous. Why? You'll find out in this exercise.In [4]:anascombe = pd.read_csv('data/anscombe.csv')anascombe.head()Out[4]: ...
2018-06-12 10:43:46 195
原创 2018.5.30 python作业:scipy exercise
题目:Exercise 10.1: Least squares Generate matrix A ∈ Rm×n with m > n. Also generate some vector b ∈ Rm. Now find x = argminxkAx−bk2. Print the norm of the residual.(使用最小二乘法公式即可)import numpy as npimp...
2018-06-01 12:52:39 425
原创 2018.5.23 python作业:matplotlib exercise
题目:Exercise 11.1: Plotting a function Plot the function f(x) = sin^2(x−2)e^−x2 over the interval [0,2]. Add proper axis labels, a title, etc.import matplotlib.pyplot as pltimport numpy as npimport m...
2018-05-27 20:03:06 253
原创 2018.5.16 python作业:numpy exercise
题目: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.Exercise 9.1: Matrix operations Calculate A+A, A(A^T),(A^T)A and AB. W...
2018-05-20 01:45:13 191
原创 Leetcode 42. Trapping Rain Water
原题:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.The above elevation map is represented by array...
2018-05-04 22:09:41 120
原创 Leetcode 33. Search in Rotated Sorted Array
原题:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).You are given a target value to search. If found i...
2018-04-29 23:30:03 70
原创 Leetcode 45. Jump Game II
原题:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal is to ...
2018-04-28 12:05:34 89
原创 Leetcode 41. First Missing Positive
原题:Given an unsorted integer array, find the smallest missing positive integer.Example 1:Input: [1,2,0]Output: 3Example 2:Input: [3,4,-1,1]Output: 2Example 3:Input: [7,8,9,11,12]Output: 1Note:Yo...
2018-04-24 00:23:20 213
原创 2018.4.8 Python作业
第十一章 测试类11-1 城市和国家:编写一个函数,它接受两个形参:一个城市名和一个国家名。这个函数返回一个格式为City,Country的字符串,如Santiago,Chile。将这个函数存储在一个名为city_functions.py的模块中。创建一个名为test_cities.py的程序,对刚编写的函数进行测试(别忘了,你需要导入模块unittest以及要测试的函数)。编写一个名为test_...
2018-04-15 02:13:17 239
原创 2018.4.4 Python作业
第十章 文件和异常10-1 Python学习笔记:在文本编辑器中新建一个文件,写几句话来总结一下你至今学到的Python知识,其中每一行都以“In Python you can”打头。将这个文件命名为learning_python.txt,并将其存储到为完成本章练习而编写的程序所在的目录中。编写一个程序,它读取这个文件,并将你所写的内容打印三次:第一次打印时读取整个文件;第二次打印时遍历文件对象;...
2018-04-07 18:55:40 203
原创 2018.4.2 Python作业
第九章 类9-3 用户:创建一个名为User的类,其中包含属性first_name,last_name,还有用户简介通常会存储的其他几个属性。在类User中定义一个名为describe_user()的方法,它打印用户信息摘要;再定义一个名为greet_user()的方法,它向用户发出个性化的问候。创建多个表示不同用户的实例,并对每个实例都调用以上两个方法。class User(): def...
2018-04-03 19:41:30 222
原创 2018.3.28 Python作业
第八章 函数8-2 喜欢的图书:编写一个名为favorite_book()的函数,其中一个包含一个名为title的形参。这个函数打印一条消息,如“One of my favorite books is Alice in Wonderland”。调用这个函数,并将一本图书的名称作为实参传递给它。def favorite_book(title): print("One of my favori...
2018-03-30 20:16:56 316
原创 2018.3.26 Python作业
第七章 用户输入和while循环7-3 10的整数倍:让用户输入一个数字,并指出这个数字是否是10的整数倍。number = input("Please enter a number:")if int(number) % 10 == 0: print(str(number) + " is an integer multiple of 10.")else: print(str(n...
2018-03-27 19:27:40 193
原创 2018.3.21 Python作业
第六章 字典6-1 人:使用一个字典来存储一个熟人的信息,包括名、姓、年龄和居住的城市。该字典应包含键first_name、last_name、age和city。将存储在该字典的每项信息都打印出来。person = {'first_name': 'Stan', 'last_name': 'Marsh', 'age': 10, 'city': 'South Park'}for key, value...
2018-03-24 16:30:57 284
原创 2018.3.19 Python作业
第五章 if语句5-5 外星人颜色#3:假设在游戏中刚射杀了一个外星人,请创建一个名为alien_color的变量,并将其设置为‘green’、‘yellow’或‘red’。编写if-elif-else语句:如果外星人是绿色的,就打印一条消息,指出玩家获得了5个点。如果外星人是黄色的,就打印一条消息,指出玩家获得了10个点。如果外星人是红色的,就打印一条消息,指出玩家获得了15个点。编写这个程序的...
2018-03-20 19:26:33 361
原创 2018.3.14 Python作业
第四章 操作列表4-2 动物:想出至少三种有共同特征的动物,将这些动物的名称存储在一个列表中,再使用for循环将每种动物的名称都打印出来。修改这个程序,使其对每种动物都打印一个句子,如“A dog would make a great pet”在程序末尾添加一行代码,指出这些动物的共同之处,如打印诸如“Any of these animals would make a great pet”这样的句...
2018-03-16 13:54:58 380
原创 2018.3.12 Python作业
第三章 列表简介3-3 自己的列表:想想自己的通勤方式,如骑摩托车或开汽车,并创建一个包含多种通勤方式的列表。根据该列表打印一系列有关这些通勤方式的宣言,如“I would like to own a Honda motorcycle.”。trans = ["motorcycle", "bike", "car"]for t in trans: print("I would like to...
2018-03-13 12:29:46 235
原创 2018.3.5 Python作业
在Python官网中,会以图片的形式阐述关于Python语法的简要介绍,同时还有Python的特点说明:函数定义、复合的数据类型、解释直观、易于学习等。从而了解到Python是一种适合初学者学习的解释型语言。主页中还有文件教程、社区以帮助学习、交流,同时可以获取社区大牛们的代码以便参考。因此,我们可以多逛Python社区中心,了解大牛们的学习心得与学习方法并进行实践,从而提高自己的Py...
2018-03-10 16:31:27 181
原创 2018.3.7 Python作业
第二章 变量和简单数据类型2-1 简单消息:将一条消息存储到变量中,再将其打印出来。message = "Hello world"print(message)2-2 多条简单消息:将一条消息存储到变量中,将其打印出来;再将变量的值修改为一条新消息,并将其打印出来。message = "Hello world"print(message)message = "Hello python"pri...
2018-03-09 19:55:25 362
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人