自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(22)
  • 收藏
  • 关注

原创 (PAT 甲级)1013 Battle Over Cities

1013 Battle Over Cities (25 分)It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We...

2019-02-27 14:52:03 118

原创 (PAT 甲级)1012 The Best Rank

To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mathematics (Calculus or Linear Algrbra), and E - Eng...

2019-02-25 19:17:56 106

原创 sklearn练习

代码如下:from sklearn import *from sklearn.model_selection import KFoldfrom sklearn.naive_bayes import GaussianNBfrom sklearn.svm import SVCfrom sklearn.ensemble import RandomForestClassifierimport n...

2018-06-19 17:20:07 247

原创 Python 数据处理练习

代码:import randomimport numpy as npimport scipy as spimport pandas as pdimport matplotlib.pyplot as pltimport seaborn as snsimport statsmodels.api as smimport statsmodels.formula.api as smfa...

2018-06-12 15:42:11 1114

原创 Scipy练习

from scipy.optimize import least_squares import numpy as np n = 2 m = 3 A = [[np.random.randint(1, 100) for i in range(m)] for j in range(n)]print("A:") print(A) b = [np.random.r...

2018-06-05 15:38:45 144

原创 Matplotlib练习

import numpy as npimport matplotlib.pyplot as pltfrom scipy import linalgx = np.arange(0, 2.00,0.01)y = np.sin((x-2) * np.exp(-x**2)) ** 2plt.plot(x, y)plt.title("f(x) = [(sin(x-2))^2]*e^(-x^2)...

2018-05-29 16:20:12 121

原创 numpy练习

Generate matrices A, with random Gaussian entries, B, a Toeplitz matrix, where A ∈Rn×m and B ∈Rm×m, for n = 200, m = 500.说明:由于这里的矩阵A,B都是随机生成的,并且都很巨大,因此不方便展示运行结果,这里的练习仅展示代码。初始化:import numpy as np imp...

2018-05-22 19:21:27 161

原创 Python 的 LeetCode 之旅(4):57 Insert Interval

原题链接:https://leetcode.com/problems/insert-interval/description/题目描述:Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the inte...

2018-05-11 21:44:27 99

原创 Python 的 LeetCode 之旅(3):120. Triangle

120. Triangle: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, given the following triangle[ [2], [3,4]...

2018-04-30 00:02:57 139

原创 Python 的 LeetCode 之旅(2):198. House Robbersss

198. House RobberYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is th...

2018-04-29 23:24:09 146

原创 Python 的 LeetCode 之旅(1):41. First Missing Positive

LeetCode题号:41题目内容: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,1...

2018-04-24 23:26:45 107

原创 第十一章

11-1 城市和国家:编写一个函数,它接受两个形参:一个城市名和一个国家名。这个函数返回一个格式为City, Country 的字符串,如Santiago, Chile 。将 这个函数存储在一个名为city_functions.py的模块中。创建一个名为test_cities.py的程序,对刚编写的函数进行测试(别忘了,你需要导入模块unittest 以及要测试的函数)。编写一个名为test_ci...

2018-04-16 10:20:09 104

原创 第十章

10-1 Python学习笔记 学习笔记 :在文本编辑器中新建一个文件,写几句话来总结一下你至此学到的Python知识,其中每一行都以“In Python you can”打头。将这个文件命名为 learning_python.txt,并将其存储到为完成本章练习而编写的程序所在的目录中。编写一个程序,它读取这个文件,并将你所写的内容打印三次:第一次打印时读取整个 文件;第二次打印时遍历文件对象;第...

2018-04-06 11:38:59 241

原创 第九章

9-3 用户 用户 :创建一个名为User 的类,其中包含属性first_name 和last_name ,还有用户简介通常会存储的其他几个属性。在类User 中定义一个名 为describe_user() 的方法,它打印用户信息摘要;再定义一个名为greet_user() 的方法,它向用户发出个性化的问候。创建多个表示不同用户的实例,并对每个实例都调用上述两个方法。class User(): ...

2018-04-06 10:44:17 199

原创 第八章

8-2 喜欢的图书 :编写一个名为favorite_book() 的函数,其中包含一个名为title 的形参。这个函数打印一条消息,如One of my favorite books is Alice in Wonderland 。调用这个函数,并将一本图书的名称作为实参传递给它def favorite_book(title): print("One of my favorite books i...

2018-03-28 20:41:34 209

原创 第七章

7-1 汽车租赁 :编写一个程序,询问用户要租赁什么样的汽车,并打印一条消息,如“Let me see if I can find you a Subaru”。car = input("Please input a kind of car:")print("Let me see if I can find you a " + car)Please input a kind of car: S...

2018-03-26 09:29:55 242

原创 第六章

6-1 人 :使用一个字典来存储一个熟人的信息,包括名、姓、年龄和居住的城市。该字典应包含键first_name 、last_name 、age 和city 。将存储在该字典中 的每项信息都打印出来。test = {'first_name':'Yingjie','last_name':'Liu','age':'20','city':'Shan Dong'}for k,v in test.item...

2018-03-25 11:31:17 872

原创 第五章

5-5 外星人颜色 :将练习5-4中的if-else 结构改为if-elif-else 结构。 ·如果外星人是绿色的,就打印一条消息,指出玩家获得了5个点。 ·如果外星人是黄色的,就打印一条消息,指出玩家获得了10个点。 ·如果外星人是红色的,就打印一条消息,指出玩家获得了15个点。for i in range(0,3): alian_color = input() if alia...

2018-03-19 22:08:07 189

原创 第四章

4-2 动物:想出至少三种有共同特征的动物,将这些动物的名称存储在一个列表中,再使用for 循环将每种动物的名称都打印出来。 ·修改这个程序,使其针对每种动物都打印一个句子,如“A dog would make a great pet”。 ·在程序末尾添加一行代码,指出这些动物的共同之处,如打印诸如“Any of these animals would make a great pet!”这样的句...

2018-03-16 10:23:03 538

原创 列表练习

3-1 姓名:将一些朋友的姓名存储在一个列表中,并将其命名为names 。依次访问该列表中的每个元素,从而将每个朋友的姓名都打印出来。names = ['L.Yingjie','C.Haowei','C.Deyi','D.Jiawei']for name in names: print(name)L.YingjieC.HaoweiC.DeyiD.Jiawei3-2 问候语:继续...

2018-03-12 17:39:42 812

原创 第二章练习

2-2 多条简单消息: 将一条消息存储到变量中,将其打印出来;再将变量的值修改为一条新消息,并将其打印出来。 >>> message = "This is a simple string.">>> print(message)This is a simple string.>>> message = "This is another si...

2018-03-09 11:21:53 141

原创 初识Python

    在Python.org和参考书上简单了解了一下Python这门语言,比较深的映像是其简洁性和易读性,这也是Python设计者的初衷。其语法特点中用缩进来代替传统的格式分隔符号,强制了程序员养成良好的编程代码风格,这也是Python有其简洁性和易读性的重要原因之一。这个特点导致了其与传统编程语言之间的差异性,需要一段时间去适应。    Python是一门强大的语言,在网页开发、界面设计、科学...

2018-03-05 17:48:49 108

空空如也

空空如也

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

TA关注的人

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