![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
作业
文章平均质量分 59
睡觉的小木头人
这个作者很懒,什么都没留下…
展开
-
python学习第二章变量和简单数据类型的部分课后练习自己尝试的代码
2-1:mes = "Hello"print(mes)2-2:mes = "Hello"print(mes)mes = "world"print(mes)2-3:name = "eric"print("Hello "+name.title()+",would you" " like to learn some Python today?")2-4:name =原创 2018-03-08 14:28:04 · 251 阅读 · 0 评论 -
scipy的题目自己尝试的代码
#Exercise 10.1import numpy as npm = 20n = 10A = np.random.randn(m,n)b = np.random.randn(m)x = np.linalg.lstsq(A,b) print(x)#Exercise 10.2import numpy as npfrom scipy import optimize as op#x = np.linsp...原创 2018-06-05 16:44:56 · 164 阅读 · 0 评论 -
matplotlib的题目
11.1:#Exercise 11.1import matplotlib.pyplot as pltimport numpy as npx = np.linspace(0,2,1000)y = np.multiply(np.power(np.sin(x-2),2),np.exp(-np.power(x,2)))plt.plot(x,y,label='$sin^2(x-2)*e^(-x^2)$')p...原创 2018-05-29 12:30:28 · 518 阅读 · 0 评论 -
Numpy的6道习题
9.1题是进行矩阵的运算,由于这些操作都已经有对应的函数,所以只用直接调用函数即可#Exercise 9.1import numpy as npfrom scipy.linalg import toeplitzdef caculate_with_k(A,B,m,k): I = np.eye(m,m,0) return np.dot(A,B-k*I)n = 200m = 500k = np.rand...原创 2018-05-17 22:59:50 · 364 阅读 · 0 评论 -
leetcode题目。题号1
题目描述:给定一个整数数组和一个目标值,找出数组中和为目标值的两个数。你可以假设每个输入只对应一种答案,且同样的元素不能被重复利用。示例:给定 nums = [2, 7, 11, 15], target = 9 因为 nums[0] + nums[1] = 2 + 7 = 9 所以返回 [0, 1]解题思路:循环遍历所有可能,每一次判断是否与target相等即可代码:class Solution...原创 2018-04-26 23:37:21 · 139 阅读 · 0 评论 -
leetcode题目。题号357
题目描述:给定一个非负整数 n,计算各位数字都不同的数字 x 的个数,其中 0 ≤ x < 10n。示例:给定 n = 2,返回 91。(答案应该是除[11,22,33,44,55,66,77,88,99]外,0 ≤ x < 100 间的所有数字)解题思路: 首先,n可以表示这最大可以是个几位数,比如n=2.说明x的范围是个1~2位的数。(n=0为特殊情况,单独讨论) ...原创 2018-05-02 22:02:44 · 229 阅读 · 0 评论 -
leetcode题目。题号12
题目描述:罗马数字包含以下七种字符: I, V, X, L,C,D 和 M。字符 数值 I 1 V 5 X 10 L 50 C 100 D 500 M 1000例如, 罗马数字 2 写做 II ,即为两个并列的 1...原创 2018-04-23 21:40:58 · 120 阅读 · 0 评论 -
python学习第十章文件和异常部分课后练习自己尝试的代码
10-1:with open('learning_python.txt') as file_object: contence = file_object.read() print(contence) with open('learning_python.txt') as file_object: for line in file_object: print(l...原创 2018-04-05 22:47:37 · 316 阅读 · 0 评论 -
python学习第八章函数部分课后练习自己尝试的代码
8-1:def display_message(): print("We learn function")display_message()8-2:def favorite_book(book_name): print("One of my favorite book is "+book_name)favorite_book("ABC")8-5:def describe_city(ci...原创 2018-03-28 22:44:02 · 395 阅读 · 0 评论 -
python学习第十一章测试代码部分课后练习自己尝试的代码
11-1:def city_functions(city,country): return city+","+countryimport unittestclass Test_City(unittest.TestCase): def test_city_country(self): string = city_functions("Santiago","Chile") ...原创 2018-04-10 14:28:23 · 185 阅读 · 0 评论 -
python学习第九章类部分课后练习自己尝试的代码
9-1:class Restaurant(): def __init__(self,restaurant_name,cuisine_type): self.restaurant_name=restaurant_name self.cuisine_type=cuisine_type def describe_restaurant(self): p...原创 2018-04-02 21:54:25 · 119 阅读 · 0 评论 -
python学习第六章字典部分课后练习自己尝试的代码
6-1:friend = {'first_name':'zhang','last_name':'san','age':18,'city':'GuangZhou'}print(friend)6-2:favorite_number = { 'zhang':1, 'li':2, 'zhao':3, 'sun':4 }for key,value in favorite_num...原创 2018-03-21 22:52:39 · 228 阅读 · 0 评论 -
python学习第七章用户输入和While循环部分课后练习自己尝试的代码
7-1:car = input()print("Let me see if I can find you a "+car)7-2:num_of_people = input("How many people are going to have dinner?")num_of_people = int(num_of_people)if num_of_people > 8: pri...原创 2018-03-26 12:39:22 · 160 阅读 · 0 评论 -
python学习第五章操作列表部分课后练习自己尝试的代码
5-1:car = 'subaru'print("Is car == 'subaru'? I predict True.")print(car == 'subaru')print("Is car == 'audi'? I predict False.")print(car == 'audi')5-4:alien_color = 'green'if alien_color == 'green': ...原创 2018-03-20 12:31:56 · 361 阅读 · 0 评论 -
python学习第三章列表的部分课后练习自己尝试的代码
3-1:names = ['zhang','li','chen']print(names[0])print(names[1])print(names[2])3-3:bicycles = ['trek','cannondale','redline','specialized']for bicycle in bicycles: print("I would like to own a "+bic...原创 2018-03-12 22:18:24 · 209 阅读 · 0 评论 -
初看python的发现与收获以及目标
初学python,老师建议我可以先去浏览下python的主页(但是全英文,而且不知该看哪里)。所以我选择了先看了教材的前面一点知识。python和C/C++不同,它是一门解释语言,不需要像C/C++那样要先编译成一个可执行文件,这样也许更方便我以后在编写一些小程序的过程中进行debug,而且python一行就是一条语句,缩进就代表了层次关系,这样对于我这种新手来说是个强制让我去适应写代...原创 2018-03-06 19:03:38 · 335 阅读 · 0 评论 -
python学习第四章操作列表部分课后练习自己尝试的代码
4-1:pizzas = ['a','b','c']for pizza in pizzas: print("I like "+pizza+" pizza")print("I really love pizzas!")4-2:animals = ['dog','cat','fish']for animal in animals: print("A "+animal+" would mak...原创 2018-03-14 23:04:17 · 209 阅读 · 0 评论 -
jupyter作业
%matplotlib inlineimport 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 ...原创 2018-06-12 17:18:02 · 295 阅读 · 0 评论