自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Python第十五周作业

题目:In the second ML assignment you have to compare the performance ofthree di↵erent classification algorithms, namely Naive Bayes, SVM, andRandom Forest.For this assignment you need to generate a rand...

2018-06-19 19:34:11 328

原创 Python第十四周作业

题目:https://nbviewer.jupyter.org/github/schmit/cme193-ipython-notebooks-lecture/blob/master/Exercises.ipynb前置:import randomimport numpy as npimport scipy as spimport pandas as pdimport matplotlib....

2018-06-13 11:11:58 302

原创 Python-scipy第十三周作业

Exercise 10.1import numpy as npm = 10n = 5A = np.mat(np.random.randn(m,n))b = np.mat(np.random.randn(m,1))x = np.array(np.linalg.lstsq(A,b,rcond=-1)[0])res = np.array(np.linalg.lstsq(A,b,rcond=...

2018-06-06 20:18:16 202

原创 Python-matplotlib第十二周作业

Exercise11.1import numpy as npimport matplotlib.pyplot as pltx = np.linspace(0,2,200)f1 = x-2f2 = np.exp(-1 * np.power(x,2))f3 = np.sin(f1 * f2)y = np.power(f3,2)plt.plot(x,y,'r',linewidth=2)...

2018-05-30 00:23:10 215

原创 Python-numpy第十一周作业

Generate matrices A, with random Gaussian entries, B, a Toeplitz matrix, where A 2 Rnm and B 2 Rmm,for n = 200, m = 500.import numpyimport randomfrom scipy.linalg import toeplitzA = numpy.random.no...

2018-05-22 00:32:10 293

原创 Python第九周LeetCode

4. Median of Two Sorted Arrays给出两个已经排好序的整数列表,求中位数。这一题考验的是如何降低时间复杂度,虽然说我用最简单的方法也可以做出来:class Solution(object): def findMedianSortedArrays(self, nums1, nums2): """ :type nums1: List[i...

2018-05-03 15:27:48 120

原创 Python第八周LeetCode

12. Integer to Roman和之前一题反过来的题目,num范围是1-3999,于是思路也反过来就好:class Solution(object): def intToRoman(self, num): """ :type num: int :rtype: str """ roman = [ ...

2018-05-02 14:29:29 128

原创 Python第八周LeetCode

13. Roman to Integer题目要求:将表示罗马数字的字符串转换为整型数字一开始是简单粗暴的一个个字符检查(因为有4和9这样的数字所以不方便使用遍历):class Solution(object): def romanToInt(self, s): """ :type s: str :rtype: int """...

2018-05-02 13:50:33 79

原创 Python第八周LeetCode

66.Plus One (Array)题目要求:将一个用列表表示的数字加1,其实这一题很简单了,但是很容易漏掉一些进位的情况,比如最高位的进位或进位不止一次:class Solution(object): def plusOne(self, digits): """ :type digits: List[int] :rtype: List[i...

2018-05-02 11:13:14 100

原创 Python第六周第二次作业

本章开始学习pygame12-1 蓝色天空一开始我完全是根据书上的例子写的,然而将12-1不需要的代码删除,结果Pygame窗口发生了未响应的状况,检查后得知是因为我将监视输入的代码也删掉了,因此无法响应我的外部输入……import sys #use this module to quitimport pygamedef run_game(): #initialize the ba...

2018-04-15 00:32:19 418

原创 Python第六周第一次作业

学习测试类的使用11-1 城市与国家def city_country(city, country): return city.title() + ", " + country.title() import unittestfrom city import city_countryclass CityTestCase(unittest.TestCase): def te...

2018-04-14 01:06:22 408

原创 Python第五周第二次作业

学习文件的处理  10-1 学习笔记创建一个名为note的txt文档with open('note.txt') as fil: context = fil.read()print(context)print() with open('note.txt') as fil: for line in fil: print(line.strip())prin...

2018-04-08 00:12:12 187

原创 Python第五周第一次作业

学习类的使用9-1 餐馆在这之前我一直以为__init__两个下划线是指前后两个,原来是前后各两个……class Restaurant(): def __init__(self, res_name, res_type): self.res_name = res_name self.res_type = res_type def descri...

2018-04-07 22:11:24 213

原创 Python第四周第二次作业

该章学习函数的使用8-2 喜欢的图书def favorite_book(title): print("One of my favorite books is " + title + ".")book = input("Input your favorite book:")favorite_book(book)8-4 大号T恤def make_shirt(size="L", word...

2018-03-28 22:37:05 163

原创 Python第四周第一次作业

学习input和while的用法7-3 10的整数倍int()和input()还可以叠起来使用但是若输入的字符是错误的字母就会使整个程序出错,要检查的话会很麻烦啊……number = int(input("Please input a number:"))print("Is the number an integral multiple of 10?")if 0 == number%10: ...

2018-03-27 15:13:35 393

原创 Python第三周第二次作业

本章学习字典的使用6-3 词汇表alphabet = { 'cin': 'to input some datas', 'cout': 'to output some datas', 'print': 'to output some datas', 'upper': 'to make letter become upper', 'lower': 'to mak...

2018-03-21 23:33:40 221

原创 Python第三周第一次作业

学习if语句的使用5-5 外星人颜色alien_color = "green"print("alien_color is " + alien_color +".")if alien_color == "green": print("You get 5 scores!")elif alien_color == "yellow": print("You get

2018-03-20 14:46:32 220

原创 Python第二周第二次作业

4-2 动物学习使用for循环遍历列表#coding:gbk#包含动物的列表animals = ["bird", "cat", "dog", "hamster"]for ani in animals: print(ani)for ani in animals: print("A " + ani + " would make a great pet.")print

2018-03-14 22:14:45 393

原创 Python第二周第一次作业

该节学习了有关列表元素的知识点3-1 姓名#coding:gbk#访问列表中的元素names = ["Alice", "Bob", "Cathy", "David"]print("The first friend is: ", names[0])print("The second friend is: ", names[1])print("The third frie

2018-03-13 00:13:29 341

原创 Python第一周编程作业

2-2 多条简单消息实现了输入字符串和输出字符串*其中遇到了一个问题:当我输入注释后发现该程序无法运行,原来是中文注释需要特别标注一句:#coding:gbk#coding:gbk# 将一条消息存储到变量中,将其打印出来;再将变量的值修改为一条新消息,并将其打印出来message = input("Please input a message:")print(message)messag...

2018-03-11 21:26:48 219

原创 Python第一周第一次作业

今天开始学习Python,首先浏览的是Python官网(https://www.python.org)该网站的页面非常好看~正中央展示了Python的一些示例,用以说明该语言的优点:自定义、多功能、直观性、简明性等等;下方则是网站各模块内容的简单展示。从几个示例中,我可以知道的是:Python和C++等编程语言最明显的区别是编写风格不同:C只需要每一句语句的完整性,而不在意排列方式,每一部分模块的...

2018-03-06 23:25:32 269

空空如也

空空如也

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

TA关注的人

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