
python学习
wlllssd
这个作者很懒,什么都没留下…
展开
-
测试博客——Hello World
测试一下第一个博客,看一下效果。 先输入一个C++代码:#include <iostream>using namespace std;int main(int argc, char const *argv[]){cout << "Hello World!" << endl;return 0;} 再输入...原创 2018-03-05 19:47:38 · 173 阅读 · 0 评论 -
教材第十一章课后习题
11.1代码:#city_functions.pydef city_country(city,country): return(city.title()+', '+country.title())#test_cities.pyimport unittestfrom city_functions import city_countryclass CitiesTest(uni...原创 2018-04-10 19:36:35 · 480 阅读 · 0 评论 -
Leetcode #561
561. Array Partition IGiven an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), …, (an, bn) which makessum ofmin(ai, bi) for all i from 1...原创 2018-04-23 12:45:19 · 217 阅读 · 0 评论 -
Leetcode #4
4.Median of Two Sorted ArraysThere are two sorted arraysnums1andnums2of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log ...原创 2018-04-30 23:32:59 · 128 阅读 · 0 评论 -
Leetcode #746
746.Min Cost Climbing StairsOn a staircase, thei-th step has some non-negative costcost[i]assigned (0 indexed).Once you pay the cost, you can either climb one or two steps. You need to find...原创 2018-05-02 23:07:02 · 125 阅读 · 0 评论 -
numpy部分习题
题目:代码:from scipy import linalgimport numpy as npn=200m=500A = np.random.normal(0,1,n*m).reshape(n,m)B = linalg.toeplitz(list(range(0,m)))题目9.1:代码:# 9.1def fun1(x): # A(B - λ*I) ...原创 2018-05-22 21:59:16 · 508 阅读 · 0 评论 -
Matplotlib部分习题
题目11.1代码:from scipy import linalgimport numpy as npfrom matplotlib import pyplot#11.1X = np.arange(0, 2.05, 0.05)Y = np.sin((X - 2) * np.exp(-X ** 2)) ** 2pyplot.plot(X, Y)pyplot.title("...原创 2018-05-25 16:58:28 · 387 阅读 · 0 评论 -
Scipy部分习题
题目10.1:代码:import numpy as np from scipy.linalg import * m=10n=5A = np.random.randint(0,30,size=(m,n)) b = np.random.randint(0,20,size=(m,1)) x, res, rnk, s = lstsq(A, b) b1 = norm(b-...原创 2018-06-02 22:19:42 · 262 阅读 · 0 评论 -
CME193习题
题目1:代码1:# your code herex_mean=anascombe.groupby('dataset')['x'].mean() y_mean=anascombe.groupby('dataset')['y'].mean()x_var=anascombe.groupby('dataset')['x'].var() y_var=anascombe.groupb...原创 2018-06-10 23:26:41 · 839 阅读 · 0 评论 -
教材第十章课后习题 (部分)
代码:#10.1print(10.1)filename = 'test.txt'print("直接读取")with open(filename) as file: contents = file.read(); print(contents)print("逐行存储后读取")sentences = []with open(filename) as file: for li...原创 2018-04-04 20:06:48 · 906 阅读 · 0 评论 -
教材第九章课后习题 (部分)
代码:#9.1print(9.1)class Restaurant(): def __init__(self,name,cuisine_type,number_served=0): self.name = name self.cuisine_type = cuisine_type self.number_served = number_served def descri...原创 2018-04-02 16:29:09 · 728 阅读 · 0 评论 -
浏览python.org的发现 和 成为python高手后的目标
python主页上一进去就有图片的展示,其中显示了python最吸引人的五大特性。整个网页的布局也十分简洁明了,非常的干净,与python其语言本身的风格保持了高度的一致性。在主页上捣腾了一阵,发现其中提供了一个在线的console可以在其中编写python的程序,我试用了一下,确实是可以使用的。许多公司都使用python进行编程开发,包括Youtube, Go...原创 2018-03-07 11:21:17 · 429 阅读 · 0 评论 -
教材第二章课后习题
代码:# 2.1print("2.1")str1 = "Python is interesting."print(str1)#2.2print("2.2")str2 = "Python is interesting."print(str2)str2 = "C++ is interesting."print(str2)#2.3print("2.3")str3原创 2018-03-08 13:03:10 · 196 阅读 · 0 评论 -
教材第三章课后习题(部分)
代码:#3.1names = ['alan','jade','mike']for i in names: print(i,end=" ")print()#3.2for i in names: print(i+", are you ok?")print()#3.3str3 = ['car','bike','bus']for i in str3: print("I l...原创 2018-03-12 17:26:54 · 359 阅读 · 0 评论 -
教材第四章课后习题
代码:#4.1print(4.1)list1 = ['chicken','beef','fish']for i in list1: print("I like " + i + " pizza.")print("I really love pizza!")#4.2print(4.2)list2 = ['dog','cat','wolf']for i in list2: p...原创 2018-03-14 22:15:43 · 1494 阅读 · 0 评论 -
教材第五章课后习题
代码:#5.1#print(5.1)#print("一个简单的条件测试,可以理解比较后为何返回True或False")#有点长,以及简单,就不写了#5.2print(5.2)#前面几个都比较简单,就不写了#写一下特定的值在列表中的查找list2 = ["one","two","three",1,2,3]if "one" in list2: print("one in l.原创 2018-03-18 01:25:11 · 345 阅读 · 0 评论 -
教材第六章课后习题 (部分)
代码:#6.1print(6.1)friend_information = { 'first_name' : 'Jack', 'last_name' : 'Ma', 'age' : 18, 'living city' : 'Hong Kong'}for key,value in friend_information.items(): print(key,":",value)...原创 2018-03-23 00:28:57 · 353 阅读 · 0 评论 -
教材第七章课后习题 (部分)
代码:#7.3print(7.3)num3 = int(input("Please input a num:"))if num3 % 10 == 0: print(str(num3)+" is a multiplier of 10.")else: print(str(num3)+" is not a multiplier of 10.")print()#7.8print(...原创 2018-03-26 13:52:56 · 356 阅读 · 0 评论 -
教材第八章课后习题 (部分)
代码:#8.1def display_message(): print(8.1) print("display_message function runs.") print()display_message()#8.2def favorite_book(book_name): print("My favorite book is "+book_name+".")print...原创 2018-03-29 18:00:37 · 610 阅读 · 0 评论 -
Sklearn部分习题
题目:步骤一:代码:from sklearn import datasetsX,Y=datasets.make_classification(n_samples=1000,n_features=10,n_classes=2)print(X)print(Y)输出:[[-1.80647012 -1.43419604 -0.28311776 ... -0.53762...原创 2018-06-18 22:04:50 · 532 阅读 · 0 评论