Python课程
yeziqing10
这个作者很懒,什么都没留下…
展开
-
python课程作业——第9章 类
第9章 类 # 9-2class User(): """用户""" def __init__(self, first_name, last_name): """初始化姓名""" self.first_name = first_name.title() self.last_name = last_name.原创 2018-06-08 22:28:16 · 660 阅读 · 0 评论 -
python课程作业——第10章 文件和异常
第10章 文件和异常# 10-11# number_writer.pyimport jsonnum_str = input("Please input your favourite number: ")num = int(num_str)with open('num.json', 'w') as fout: json.dump(num, fout)# number_...原创 2018-06-09 00:33:44 · 207 阅读 · 0 评论 -
python课程作业——第11章 测试代码
第11章 测试代码 # 11-1# city_functions.pydef get_formatted_city_name(city, country): """生成规范格式的城市名""" return city.title() + ', ' + country.title()# main.pyimport unittestfrom city_func...原创 2018-06-09 00:35:33 · 230 阅读 · 0 评论 -
python课程作业——Leetcode 2. Add Two Numbers
DescriptionYou 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...原创 2018-06-09 19:43:43 · 132 阅读 · 0 评论 -
python课程作业——Leetcode 3. Longest Substring Without Repeating Characters
DescriptionGiven a string, find the length of the longest substring without repeating characters.Solution维护一个lp, rp和mp,mp表示s(lp,rp]中所有字母-位置的dict,双指针扫描即可Codeclass Solution: def lengthOfLo...原创 2018-06-09 20:14:47 · 91 阅读 · 0 评论 -
python课程作业——Leetcode 6. ZigZag Conversion
DescriptionThe string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H N...原创 2018-06-09 20:39:08 · 207 阅读 · 0 评论 -
python课程作业——Leetcode 31. Next Permutation
DescriptionImplement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowe...原创 2018-06-09 21:13:03 · 133 阅读 · 0 评论 -
python课程作业——numpy
以下是用jupyter notebook导出markdown格式的文件,对应输入输出。。import numpy as npfrom scipy.linalg import toeplitzn = 200m = 500A = np.random.randn(n, m)B = toeplitz(np.arange(m))I = np.eye(m,m)print(A)pri...原创 2018-06-10 23:22:26 · 489 阅读 · 0 评论 -
python课程作业——matplotlib
import matplotlib.pyplot as pltimport numpy as npimport seaborn as sns# 11-1def f(x): return np.sin(x-2)**2 * np.exp(-x**2)x = np.arange(0, 2, 0.001)plt.plot(x, f(x), label='$\sin^2(x-2...原创 2018-06-11 00:56:01 · 393 阅读 · 0 评论 -
python课程作业——第8章 函数
第8章 函数# 8-12def printMaterial(name, *materials): print("costumer " + name + ":") for material in materials: print(material) print()printMaterial("John", "beef", "tuna")pri...原创 2018-06-08 22:27:37 · 122 阅读 · 0 评论 -
python课程作业——第7章 字典
第7章 字典# 7-8sandwich_orders = ['tuna sandwich', 'peanut sandwich', 'veal sandwich']finished_sandwiches = []while sandwich_orders: sandwich = sandwich_orders.pop() print('I made your ' + ...原创 2018-06-08 22:26:28 · 319 阅读 · 0 评论 -
python课程作业——第1章 起步
第1章 起步1. 浏览 Python 主页(https://www.python.org/),在博客上写下你有哪些发现和收获下载了最新Python 3.6.4 与 Python 2.7.14 点开文档查看最新的更新 看Use Python for … 版块,了解热门Python库2. 假设你已经成为一位 Python 编程高手,你打算实现怎样的程序?在博客上写下你的目标.学会如...原创 2018-06-08 22:15:07 · 404 阅读 · 0 评论 -
python课程作业——第2章 变量和简单数据类型
第2章 变量和简单数据类型# 2-3name = "Eric"print("Hello " + name + ", would you like to learn some Python today?")# 2-4name = "Albert Einstein"print(name.upper())print(name.lower())print(name.titl...原创 2018-06-08 22:16:47 · 254 阅读 · 0 评论 -
python课程作业——第3章 列表简介
第3章 列表简介# 3-4inviter = ["Alice", "Bob", "Cindy"]for member in inviter: print("Welcome " + member + ", you are invited to the dinner")# 3-5inviter = ["Alice", "Bob", "原创 2018-06-08 22:18:43 · 131 阅读 · 0 评论 -
python课程作业——第4章 操作列表
第4章 操作列表 # 4-1pizzas = ["fruit pizza", "beef pizza", "seafood pizza"]for pizza in pizzas: print("I like " + pizza)print("I really love pizza!")# 4-10a = list(range(1, 12))print(a)pri...原创 2018-06-08 22:20:01 · 273 阅读 · 0 评论 -
python课程作业——第5章 if语句
第5章 if语句# 5-8users = ["Alice", "Bob", "Cindy", "Doug", "Eric", "admin"]for user in users : if user == "admin" : print("Hello admin, would you like to see a status repor原创 2018-06-08 22:21:14 · 222 阅读 · 0 评论 -
python课程作业——第6章 字典
第6章 字典# 6-8pets = [ { 'name': 'miao', 'type': 'cat', 'owner': 'Sam', }, { 'name': 'wang', 'type': 'dog', 'owner': 'Bob', }]for pe...原创 2018-06-08 22:21:56 · 1133 阅读 · 0 评论 -
python课程作业——scipy
import matplotlib.pyplot as pltimport numpy as npimport seaborn as sns# 10-1 reference: https://docs.scipy.org/doc/scipy-1.1.0/reference/tutorial/linalg.htmlfrom scipy.linalg import lstsqm...原创 2018-06-11 01:35:41 · 363 阅读 · 0 评论