![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
Henry_Liu_
这个作者很懒,什么都没留下…
展开
-
Python入门-操作列表
对教材《Python编程从入门到实践》第四章的学习和“动手试一试”的实践。4-4 一百万 :创建一个列表,其中包含数字1~1 000 000,再使用一个for 循环将这些数字打印出来(如果输出的时间太长,按Ctrl + C停止输出,或关闭输出窗口)。big_list = list(range(1, 1000001))for entry in big_list: print(entry)...原创 2018-03-15 21:04:11 · 270 阅读 · 0 评论 -
Python-Numpy相关习题及解析
Generate matrices A, with random Gaussian entries, B, a Toeplitz matrix, where A∈Rn×mA∈Rn×mA\in\mathbb{R}^{n\times m} and B∈Rm×mB∈Rm×mB\in\mathbb{R}^{m\times m}, for n=200n=200n=200, m=500m=500m=500....原创 2018-05-17 22:04:35 · 1456 阅读 · 0 评论 -
LeetCode 198.House Robber 解题分析
题目来源https://leetcode.com/problems/house-robber/description/题目描述You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constrain...原创 2018-04-28 10:32:58 · 227 阅读 · 0 评论 -
LeetCode 134.Gas Station 解题分析
题目来源:https://leetcode.com/problems/gas-station/description/题目描述:There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tan...原创 2018-05-07 01:03:04 · 334 阅读 · 0 评论 -
LeetCode 213.House Robber II 解题分析
题目来源https://leetcode.com/problems/house-robber-ii/description/题目描述Note: This is an extension of House Robber.After robbing those houses on that street, the thief has found himself a new place for his ...原创 2018-04-28 18:34:11 · 232 阅读 · 0 评论 -
LeetCode 120.Triangle 解题分析
题目来源:https://leetcode.com/problems/triangle/description/题目描述:Given a triangle, find the minimum path sum from top to bottom.Each step you may move to adjacent numbers on the row below.For example, giv...原创 2018-04-29 00:56:31 · 209 阅读 · 0 评论 -
Python-Matplotlib相关习题及解析
MatplotlibExercise 11.1: Plotting a functionPlot the function f(x)=sin2(x−2)e−x2f(x)=sin2(x−2)e−x2f(x)=\sin^2(x-2)e^{-x^2}over the interval [0,2][0,2][0,2]. Add proper axis labels, a title, et...原创 2018-05-26 12:03:47 · 2009 阅读 · 0 评论 -
Python-Scipy相关习题及解析
ScipyExercise 10.1: Least squaresGenerate matrix A∈Rm×nA∈Rm×nA\in R^{m\times n} with m>nm>nm > n. Also generate some vector b∈Rmb∈Rmb\in R^m. Now find x=argminx∥Ax−b∥2x=argminx‖Ax−b‖2x=\...原创 2018-06-02 15:02:22 · 695 阅读 · 0 评论 -
cme193-ipython-notebooks-lecture-Exercises
github上的一个仓库 cme193-ipython-notebooks-lecture是 Stanford 的一个课程 CME193 的笔记,主要记录了 Python 下的工具 IPython, Pandas 和 StatsModels这个仓库布置了一些 Exercises我的完成:点击此处...原创 2018-06-09 12:42:19 · 265 阅读 · 0 评论 -
Python-scikit-learn 习题
Scikit-LearnAssignmentIn 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 assignmen...原创 2018-06-19 14:18:07 · 470 阅读 · 0 评论 -
LeetCode 55.Jump Game 解题分析
题目来源:https://leetcode.com/problems/jump-game/description/题目描述:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents...原创 2018-05-02 22:03:52 · 226 阅读 · 0 评论 -
Python入门-变量和简单的数据类型
对教材《Python编程从入门到实践》第二章的学习和“动手试一试”的实践。 2-2 多条简单消息:将一条消息存储到变量中,再将其打印出来;再将变量的值修改为一条新消息,并将其打印出来。代码为:结果是: 我们添加了一个名为message的变量。每个变量都存储了一个值——与变量相关联的信息。处理第一行代码时,它将文本“Hellom world!”与变量message关联起来;处理第二行代码...原创 2018-03-11 10:59:46 · 248 阅读 · 0 评论 -
探索Python主页
作为Python初学者,浏览Python主页(https://www.python.org)也许是了解Python这门语言的好方式。接下来我们就探索Python主页,看看有什么发现和收获。 打开浏览器,输入网址,进入网页。我们首先可以看到这样的画面。 如果英文看的比较吃力,且使用Chrome浏览器,可以使用浏览器自带的翻译功能,翻译准确度还是不错的。 顶上一栏有PSF(P...原创 2018-03-05 22:20:45 · 321 阅读 · 0 评论 -
Python入门-if语句
5-2 更多的条件测试 :你并非只能创建10个测试。如果你想尝试做更多的比较,可再编写一些测试,并将它们加入到conditional_tests.py中。对于下面列出的各种测试,至少编写一个结果为True 和False 的测试。检查两个字符串相等和不等。测试特定的值是否包含在列表中。测试特定的值是否未包含在列表中。name = 'HenryLiu'age = 18hobby = ['Baske...原创 2018-03-23 15:25:59 · 251 阅读 · 0 评论 -
Python入门-列表
对教材《Python编程从入门到实践》第三章的学习和“动手试一试”的实践。3-1 姓名: 将一些朋友的姓名存储在一个列表中,并将其命名为names 。依次访问该列表中的每个元素,从而将每个朋友的姓名都打印出来。代码为:names = ['Henry Liu', 'LeBron James', 'Phil Dumphy']print(names[0])print(names[1])print(...原创 2018-03-13 23:08:27 · 393 阅读 · 0 评论 -
Python入门-字典
6-5 河流 :创建一个字典,在其中存储三条大河流及其流经的国家。其中一个键—值对可能是'nile': 'egypt' 。使用循环为每条河流打印一条消息,如“The Nile runs through Egypt.”。使用循环将该字典中每条河流的名字都打印出来。使用循环将该字典包含的每个国家的名字都打印出来。river_country = {'nile':'egypt', 'amazon':'br...原创 2018-03-23 16:22:38 · 649 阅读 · 0 评论 -
Python入门-用户输入和while循环
7-2 餐馆订位 :编写一个程序,询问用户有多少人用餐。如果超过8人,就打印一条消息,指出没有空桌;否则指出有空桌。num = input("请输入有多少人用餐:")num = int(num)if num > 8: print("没有空桌了")else: print("有空桌")7-3 10的整数倍 :让用户输入一个数字,并指出这个数字是否是10的整数倍。num ...原创 2018-04-01 12:26:14 · 1039 阅读 · 0 评论 -
Python入门-函数
8-1 消息 :编写一个名为display_message() 的函数,它打印一个句子,指出你在本章学的是什么。调用这个函数,确认显示的消息正确无误。def display_message(): """简单地显示本章所学""" print("八章将要学习编写函数。包括向函数传递信息,\让函数处理信息并返回一个或一组值,\还将学习如何将函数存储在被称为模块的独立文件中,\让主程...原创 2018-04-01 16:26:48 · 492 阅读 · 0 评论 -
Python入门-测试代码
11-1 城市和国家 :编写一个函数,它接受两个形参:一个城市名和一个国家名。这个函数返回一个格式为City, Country 的字符串,如Santiago, Chile 。将这个函数存储在一个名为city_functions.py的模块中。创建一个名为test_cities.py的程序,对刚编写的函数进行测试(别忘了,你需要导入模块unittest 以及要测试的函数)。编写一个名为 的方法,核实...原创 2018-04-15 21:11:38 · 6990 阅读 · 0 评论 -
Python入门-类
9-1 餐馆 :创建一个名为Restaurant 的类,其方法__init__() 设置两个属性:restaurant_name 和cuisine_type 。创建一个名为describe_restaurant() 的方法和一个名为open_restaurant() 的方法,其中前者打印前述两项信息,而后者打印一条消息,指出餐馆正在营业。根据这个类创建一个名为restaurant 的实例,分别打印...原创 2018-04-05 20:31:07 · 1633 阅读 · 0 评论 -
Python入门-文件和异常
10-1 Python学习笔记 :在文本编辑器中新建一个文件,写几句话来总结一下你至此学到的Python知识,其中每一行都以“In Python you can”打头。将这个文件命名为learning_python.txt,并将其存储到为完成本章练习而编写的程序所在的目录中。编写一个程序,它读取这个文件,并将你所写的内容打印三次:第一次打印时读取整个文件;第二次打印时遍历文件对象;第三次打印时将各...原创 2018-04-05 22:10:53 · 379 阅读 · 0 评论 -
决策树原理和Python实现
决策树原理和Python实现github源码地址:https://github.com/HenryLiu0/decision-tree-sample1.算法原理决策树算法是机器学习中常用的分类和回归算法,而决策树学习属于有监督学习。经典的决策树模型有 ID3,C4.5 和 CART 三种,它们的区别在于选择最佳特征的原则不同。决策树如同它的名字,是一个树形的结构,它既可以是二叉树,也可...原创 2019-01-01 02:28:48 · 1044 阅读 · 0 评论