Homework
GH_Loeng
这个作者很懒,什么都没留下…
展开
-
Weak2 Chapter3 Homework
3-1 姓名names = ["Smith","Napoleon","Alexander","Lenin","Stalin"]for name in names: print(name)输出结果为:SmithNapoleonAlexanderLeninStalin3-2 问候语names = ["Smith","Napoleon&原创 2018-03-13 00:02:06 · 131 阅读 · 0 评论 -
Weak14 Jupyter homework
%matplotlib inlineimport randomimport numpy as npimport scipy as spimport pandas as pdimport matplotlib.pyplot as pltimport seaborn as snsimport statsmodels.api as smimport statsmodels.form...原创 2018-06-09 20:16:06 · 195 阅读 · 2 评论 -
Weak13 Scipy Homework
代码:import numpy as npimport matplotlib.pyplot as pltfrom scipy.optimize import leastsqm=10n=4A = np.random.randint(1,10,(m,n))b = np.random.randint(1,10,(m,1))x = np.random.randint(1,10,...原创 2018-06-03 17:04:00 · 155 阅读 · 0 评论 -
Weak12 Matplotlib Homework
代码:import numpy as npimport matplotlib.pyplot as pltimport seaborn as snsx = np.linspace(0,2,1000)y = np.power(np.sin(x-2),2)*np.exp(-np.power(x,2))plt.plot(x,y,'g-',label='$sin^2(x-2)e^-x^...原创 2018-05-25 21:36:27 · 244 阅读 · 0 评论 -
Weak11 Numpy Homework
为了显示方便,n=4,m=10 代码:import numpy as npfrom scipy.linalg import toeplitzimport randomn=4m=10A = np.random.normal(0,1,n*m)A = A.reshape(n,m)B = toeplitz(list(range(1,m+1)))print("A=",A)pr...原创 2018-05-19 20:51:37 · 340 阅读 · 0 评论 -
Weak5 Chapter10 Homework
10-1 Python学习笔记 learning_python.txtIn Python you can be angryIn Python you can be excitedIn Python you can say nothingmain.pywith open('learning_python.txt') as file: print("打印整个文件") ...原创 2018-04-05 00:04:41 · 251 阅读 · 0 评论 -
Weak6 Chapter11 Homework
11-1 城市和国家 city_functions.pydef get_city_country (city,country): return city+","+countrytest_cities.pyfrom city_functions import get_city_countryimport unittestclass NameTestCase (un...原创 2018-04-11 00:11:03 · 188 阅读 · 0 评论 -
Weak5 Chapter9 Homework
9-1 餐馆class Restaurant(): def __init__(self,name,type): self.restaurant_name = name self.cuisine_type = type def describe_restaurant(self): print("餐馆名:"+self.resta...原创 2018-04-02 20:19:12 · 138 阅读 · 0 评论 -
Weak4 Chapter7 Homework
7-2 餐馆定位i = int(input("请问有多少人用餐? "))while i > 0: if i > 8: print("目前没有空桌") else: print("目前有空桌") i = int(input("请问有多少人用餐? "))输出结果是:请问有多少人用餐? 5目前有空桌请问有多少人用餐...原创 2018-03-27 14:52:47 · 171 阅读 · 0 评论 -
Weak3 Chapter6 Homework
6-2 喜欢的数字numbers ={'carol':6,'jen':2,'sarah':4,'edward':9,'phil':1}for k,v in numbers.items(): print(k.title()+"'s favourite number is "+str(v))输出结果为:Carol's favourite number is 6Jen's...原创 2018-03-22 00:05:05 · 164 阅读 · 0 评论 -
Weak3 Chapter5 Homework
5-2 更多的测试条件#检查字符串相等和不等,lower()的测试cars = ["audi","BMW","Subaru","toyato"]for car in cars: if car.lower() == 'bmw': print(car.upper()) else: print(car.title())#检查特定值在不在列表...原创 2018-03-21 13:57:47 · 137 阅读 · 0 评论 -
Weak4 Chapter8 Homework
8-2 喜欢的图书def favourite_book(title): print("One of my favourite books is "+title)favourite_book("Alice in Wonderland")输出结果是:One of my favourite books is Alice in Wonderland8-3,8-4 T恤...原创 2018-03-30 13:16:03 · 116 阅读 · 0 评论 -
Weak2 Chapter4 Homework
4-1 披萨kinds =["apple","banana","orange"]for kind in kinds: print("I like "+kind+" pizza")print("I really love pizza!")输出结果:I like apple pizzaI like banana pizzaI like orange pizz原创 2018-03-17 21:30:44 · 145 阅读 · 0 评论 -
Weak1 Chapter2 Homework
2-1 简单消息message = "Hello world"print(message)output:Hello world2-2 多条简单消息message = "Hello world"print(message)message = "World hello"print(message)output:Hello worldWorld hello2-3 个性化消息name = "...原创 2018-03-07 22:54:44 · 237 阅读 · 0 评论 -
Weak1 浏览Python主页 and 目标
Python主页一进去用了五段代码简单展示了这种语言的特性,其中有一段代码吸引了我的注意def fib(n): a,b = 0,1 while a < n: print(a,end=" ") a,b = b,a+bfib(1000)0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 ...原创 2018-03-10 21:35:24 · 142 阅读 · 0 评论 -
Weak15 Sklearn Homework
代码:import sklearnfrom sklearn import datasetsfrom sklearn import cross_validationfrom sklearn.naive_bayes import GaussianNBfrom sklearn.svm import SVCfrom sklearn.ensemble import RandomFore...原创 2018-06-17 02:37:19 · 200 阅读 · 0 评论