- 博客(19)
- 收藏
- 关注
原创 高级编程技术 第十五周 sklearn 学习
题目:代码:#sklearn chinese document#http://cwiki.apachecn.org/display/sklearn/Indexfrom sklearn import datasetsfrom sklearn import cross_validationfrom sklearn.naive_bayes import GaussianNBfrom skle...
2018-06-19 20:37:09
264
原创 第十三周 Scipy练习
其实这道题就是利用最小二乘法求x及其残差的范数,可以直接用函数scipy.linalg.lstsq()返回的第一个值是x,第二个值是残差的范数#10.1_Least squares import numpy as npimport scipy.linalgm = 30n = 20A = np.random.rand(m,n)b = np.random.rand(m)x, resid...
2018-06-04 18:28:11
236
原创 高级编程基础 11 Matplotlib 练习
Exercise 11.1: Plotting a function Plot the functionf(x) = sin2(x−2)e−x2 over the interval [0,2]. Add proper axis labels, a title, etc.import numpy as np import matplotlib.pyplot as plt x = np...
2018-05-28 21:49:22
301
原创 高级编程技术 Numpy课后习题
0. Generate matrices A, with random Gaussian entries, B, a Toeplitz matrix, where A ∈Rn×m and B ∈Rm×m, for n = 200, m = 500.import numpy as npfrom scipy.linalg import toeplitz #0__construct A snd B...
2018-05-21 01:27:45
377
原创 LeetCode 2-Add Two Numbers
题目:You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and retur...
2018-05-02 23:14:28
129
原创 LeetCode 83. Remove Duplicates from Sorted List
题目:Given a sorted linked list, delete all duplicates such that each element appear only once.Example 1:Input: 1->1->2Output: 1->2Example 2:Input: 1->1->2->3->3Output: 1->2-&...
2018-04-28 23:24:36
119
原创 LeetCode19. Remove Nth Node From End of List
题目:Given a linked list, remove the n-th node from the end of list and return its head.代码:# Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val ...
2018-04-25 22:57:36
102
原创 LeetCode 66 Plus One
Given a non-empty array of digits representing a non-negative integer, plus one to the integer.The digits are stored such that the most significant digit is at the head of the list, and each element...
2018-04-23 20:10:20
101
原创 第11章 测试代码
10-11喜欢的数字import jsonnum=input('Please input your favorite number!')with open('number.json','w') as f_obj: json.dump(num,f_obj) with open('number.json','r') as f_obj: new_num=json.load(f_obj) p...
2018-04-09 21:56:30
130
原创 第十章 文件与异常 作业
10-1Python学习笔记with open('10-1Python.txt') as file_obj: print(file_obj.read()) with open('10-1Python.txt') as file_obj: for line in file_obj: print(line.rstrip()) with open('10-1Python.txt') a...
2018-04-04 23:45:31
222
原创 第九章 类 作业
9-1餐馆class Restaurant(): def __init__(self,restaurant_name,cuisine_type): self.restaurant_name=restaurant_name self.cuisine_type=cuisine_type def open_restaurant(self): print(self.restaurant_...
2018-04-02 23:47:04
182
原创 第8章 函数 课后习题
8-2喜欢的图书def favorite_book(title): print("One of my favorite book is "+title+".")favorite_book("Alice in Wonderland")8-3T恤def make_shirt(size,word): print("The size of the T-shirt is "+size+" and ...
2018-03-29 12:20:13
321
原创 第七章 用户输入和while循环 作业
7-2 餐馆定位num=input("How many poeple will have dinner?\n")num=int(num)if num>8: print("There is no empty.")else: print("There is a table.")7-3 10的整数倍num=input("Please input a number.\n")num=in...
2018-03-26 09:33:36
228
原创 高级编程基础第六章作业--字典
6-2最喜欢的数字favorite_num={"Alice":18,"Bob":2,"Cindy":14,"David":23,"Ella":34}for name,num in favorite_num.items(): print(name+"'s favorite number is "+str(num))6-5河流rivers={'nile':'egypt','yangtze
2018-03-22 00:01:31
173
原创 高级编程基础第五章作业--if语句
5-2更多的条件测试a='apple'b='Apple'print(a==b)print(a.lower()==b.lower())a=1.2b=3.4print(a==b)print(a!=b)print(a>b)print(a<b)print(a>=b)print(a<=b)print(a>0 and b<0)print(a>...
2018-03-19 17:39:49
200
原创 高级编程基础第四章作业
4-1比萨pizzas=["pepperoni pizza","fruit pizza","chicken pizza","bacon pizza"]for pizza in pizzas: print("I like "+pizza+".")print("I really love pizza!")4-2动物animals = ["dog"
2018-03-14 23:45:14
132
原创 高级编程基础第二次作业——列表的学习
3-1姓名names=['Alice','Bob','Tommy','Lily','Lucy']for name in names: print(name)3-2问候语names=['Alice','Bob','Tommy','Lily','Lucy']for name in names: print(name+', good morning!')3-3自己的列表transports=...
2018-03-12 21:48:16
167
原创 高级编程基础第一次作业
2-1简单消息message = "hello world!"print(message)2-2多条简单消息message="hello"print(message)message="world"print(message)2-3个性化消息name="Eric"print("Hello "+name+", would you like to learn some Python tod.
2018-03-11 14:11:18
154
原创 初学Python发现和目标
今天是我们学习高级编程基础的第一节课,这学期我们将会学习Python。老师和我们简要讲述了一些Python的特点。Python有强大的库,比如数据分析库(NumPy和SCIPython)、网站设计库(Django)、机器学习库(scikit-learn)、自然语言处理库(NLTK)等;并且Python是通过空格和换行来划分代码块,而不是通过花括号和关键词,这也是Python简洁和可读性高的主...
2018-03-05 22:59:50
399
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人