
python作业
文章平均质量分 63
学校的变成作业
qq_36325159
这个作者很懒,什么都没留下…
展开
-
Python第七章课后作业
7-1汽车租赁:str=input('What car do you want ')print('Let me see if I can find you a',str1)运行结果:7-2餐厅订位:str1=input('How many people will come to the dinner:')str1=int(str1)if str1>8: print('No empty...原创 2018-03-23 19:39:39 · 2439 阅读 · 0 评论 -
Python第六章课后作业
6-1人:inf={'first_name':'Ke','last_name':'sibo','age':21,'city':'Guangzhou'}for mes1,mes2 in inf.items(): print(mes1+':',mes2)运行结果:6-2喜欢的数字:number={'ksb':8,'lmd':7,'hyk':2,'kq':1,'lrp':5}for name,nu...原创 2018-03-22 23:05:43 · 632 阅读 · 0 评论 -
Python第五章课后作业
5-1条件测试:car = 'a'print("Is car == 'a'? I predict True.")print(car == 'a')print("\nIs car == 'b'? I predict False.")print(car == 'b')car = 'c'print("Is car == 'c'? I predict True.")print(car == ...原创 2018-03-22 17:40:20 · 11340 阅读 · 0 评论 -
Python第四章课后作业
4-1比萨:pizzas=['apple_pizza','banana_pizza','beef_pizza']for pizza in pizzas: print('I like '+pizza)print('I really like pizza')运行结果:4-2动物:animals=['dog','cat','tortoise']for animal in animals: pr...原创 2018-03-15 17:41:01 · 1163 阅读 · 0 评论 -
Python第三章课后作业
3-1姓名:names=['lmd','ksb','kq','lrp']for name in names: print(name)执行结果:3-2问候语:names=['lmd','ksb','kq','lrp']for name in names: print(name.title()+" Hi!")执行结果:3-3自己的列表:ways=['motorcycle','bicycle',...原创 2018-03-13 21:18:24 · 1888 阅读 · 0 评论 -
Python第二章课后作业
2-1简单信息:message="hello world"print(message)运行结果:2-2多条简单信息:message="hello world"print(message)message="no thanks"print(message)运行结果:2-3个性化信息:name="Ro bo"print("hello, "+name+", Good morning!")原创 2018-03-11 12:13:11 · 773 阅读 · 0 评论 -
浏览Python主页感想
浏览了Python主页:https://www.python.org/,最引人注目的就是第一句话: Python is a programming language that lets you work quickly and integrate systems more effectively. Python是让我们更高效工作并且更有效地整合系统的编程语言。我们知道Pytho...原创 2018-03-11 11:20:57 · 150 阅读 · 0 评论 -
Python学习目标
这学期学习python,虽然课本上大多数是python的语法,但也有涉及到用python做小游戏的,而我本人对游戏开发有一定兴趣,有过用unity开发游戏的经历,看到书本上书本上的飞机打外星人的游戏,我希望我自己也能做一个类似的2d小游戏,比如人物横板冒险类的。 而且python在写爬虫上是较为方便的,所以也有这方面的目标,打算用python写一点自动浏览网页获取信息的爬虫,最好就能...原创 2018-03-11 10:27:43 · 856 阅读 · 0 评论 -
Python第八章课后作业(函数)
8-1 消息:def display_message(): print("I learn function in this chapter")display_message()运行结果:8-2 喜欢的图书:def favorite_book(bookname): print("One of my favorite books is "+bookname.title(...原创 2018-03-28 21:44:18 · 672 阅读 · 0 评论 -
Python第九章课后习题
9-1 餐馆:class Restaurant(): """docstring for Restaurant""" def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type=cuisine_type def describ...原创 2018-04-04 20:35:02 · 1864 阅读 · 0 评论 -
Python第十章(文件与异常)课后习题
10-1 py学习笔记:with open('learning_python.txt') as file_object: content=file_object.read() print(content,end='')print()with open('learning_python.txt') as file_object: for line in file_object: ...原创 2018-04-12 18:26:28 · 5722 阅读 · 0 评论 -
第十一章课后习题
11-1 城市和国家:编写一个函数,它接受两个形参:一个城市名和一个国家名。这个函数返回一个格式为 City, Country 的字符串,如 Santiago, Chile。将这个函数存储在一个名为 city _functions.py 的模块中。创建一个名为 test_cities.py 的程序,对刚编写的函数进行测试(别忘了,你需要导入模块 unittest 以及要测试的函数)。编写一个名为 ...原创 2018-04-13 16:48:18 · 830 阅读 · 0 评论 -
螺旋矩阵 II
给定一个正整数n,生成一个包含 1 到n2所有元素,且元素按顺时针顺序螺旋排列的正方形矩阵。示例:输入: 3输出:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [ 7, 6, 5 ]]class Solution: def generateMatrix(self, n): """ :ty...原创 2018-04-30 17:10:48 · 125 阅读 · 0 评论 -
搜索范围
给定一个按照升序排列的整数数组nums,和一个目标值target。找出给定目标值在数组中的开始位置和结束位置。你的算法时间复杂度必须是O(logn) 级别。如果数组中不存在目标值,返回[-1, -1]。示例 1:输入: nums = [5,7,7,8,8,10], target = 8输出: [3,4]示例2:输入: nums = [5,7,7,8...原创 2018-04-30 18:16:35 · 380 阅读 · 0 评论 -
最长公共前缀
编写一个函数来查找字符串数组中的最长公共前缀。如果不存在公共前缀,返回空字符串""。示例1:输入: ["flower","flow","flight"]输出: "fl"示例2:输入: ["dog","racecar","car"]输出: ""解释: 输入不存在公共前缀。说明:所有输入只包含小写字母a-z。class Solution(ob...原创 2018-04-30 19:12:43 · 250 阅读 · 0 评论 -
罗马数字转整数
罗马数字包含以下七种字符:I,V,X,L,C,D和M。字符 数值I 1V 5X 10L 50C 100D 500M 1000例如, 罗马数字 2 写做II,即为两个并列的 1。...原创 2018-04-30 21:36:30 · 276 阅读 · 0 评论 -
全排列
给定一个没有重复数字的序列,返回其所有可能的全排列。示例:输入: [1,2,3]输出:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]def permution(first, second, res): if not second: res.append...原创 2018-04-30 21:54:11 · 135 阅读 · 0 评论 -
Binary Tree Right Side View
Given a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered from top to bottom.Example:Input:[1,2,3,null,5,null,4]Output:[1, 3...原创 2018-05-21 09:36:42 · 126 阅读 · 0 评论 -
Numpy作业题
Generate matrices A, with random Gaussian entries, B, a Toeplitz matrix, where A 2 Rn×m and B 2 Rm×m,for n = 200, m = 500.Exercise 9.1: Matrix operationsCalculate A + A, AA>; A>A and AB. ...原创 2018-05-22 10:43:42 · 249 阅读 · 0 评论 -
matplotlib作业
第一题:import numpy as npimport mathimport matplotlib.mlab as mlabimport matplotlib.pyplot as pltimport scipy.stats as scplt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签plt.rcParams[...原创 2018-06-01 12:01:28 · 268 阅读 · 0 评论 -
scipy作业
第一题主要考察最小二乘法的使用Exercise 10.2: OptimizationFind the maximum of the functionf(x) = sin2(x - 2)e-x2第二题主要考察求函数最值的方法Exercise 10.3: Pairwise distancesLet X be a matrix with n rows an...原创 2018-06-02 20:58:32 · 278 阅读 · 0 评论 -
jupyter作业
Anscombe's quartetAnscombe's quartet comprises of four datasets, and is rather famous. Why? You'll find out in this exercise.所有模块:%matplotlib inlineimport randomimport numpy as npim...原创 2018-06-11 22:18:26 · 387 阅读 · 0 评论 -
sklearn作业
直接上代码,因为都是函数都是ppt里面的也没有太多解释,具体看注释即可from sklearn import datasetsfrom sklearn import model_selectionfrom sklearn.naive_bayes import GaussianNBfrom sklearn.svm import SVCfrom sklearn.ensemble im...原创 2018-06-20 20:18:49 · 219 阅读 · 0 评论