摘要: 谏言:穷则独善其身,达则兼善天下 # 创建RandomWalk类 import matplotlib.pyplot as plt from random import choice class RandomWalk(): """一个生成随机漫步数据的表""" def __init__(self,nu 阅读全文
posted @ 2020-04-23 23:02 过气诗人 阅读(153) 评论(0) 推荐(0)
摘要: 每日一句:人生犹如一本书,愚蠢者草草翻过,聪明人细细阅读。为何如此。因为他们只能读它一次。 # 创建RandomWalk类 import matplotlib.pyplot as plt from random import choice class RandomWalk(): """一个生成随机漫 阅读全文
posted @ 2020-04-22 23:27 过气诗人 阅读(128) 评论(0) 推荐(0)
摘要: 每日一句:我们应该不虚度一生,应该能够说:"我已经做了我能做的事" 数据可视化 # 安装matplotlib import matplotlib.pyplot as plt squares = [1,4,9,16,25] plt.plot(squares) plt.show() # 绘制简单的折线图 阅读全文
posted @ 2020-04-21 23:04 过气诗人 阅读(240) 评论(0) 推荐(0)
摘要: 每日一句:人生犹如一本书,愚蠢者草草翻过,聪明人细细阅读。为何如此。因为他们只能读它一次 name_funcation.py def get_formatted_name(first,last): """生成整洁的姓名""" full_name=first+' '+last return full_ 阅读全文
posted @ 2020-04-20 22:18 过气诗人 阅读(135) 评论(0) 推荐(0)
摘要: 每日一句:生活中没有理想的人,是可怜的人。 # 异常 # 报错 # 处理ZeroDivisionError # print(5/0) # 会报错 division by zero # 使用try-except代码块 处理异常 try: print(5/0) except ZeroDivisionEr 阅读全文
posted @ 2020-04-19 23:21 过气诗人 阅读(159) 评论(0) 推荐(0)
摘要: 每日一句:愿每次回忆,对生活都不感到负疚。 将car.py进行优化分解,通过导入模块的方式进行实现 car.py class Car(): """一次模拟汽车的简单尝试""" ​ def __init__(self, make, model, year): # 制造商,型号,年份 """初始化描述汽 阅读全文
posted @ 2020-04-18 23:15 过气诗人 阅读(216) 评论(0) 推荐(0)
摘要: 每日一句:最可怕的敌人,就是没有坚强的信念。 class Car(): """一次模拟汽车的简单尝试""" def __init__(self, make, model, year):# 制造商,型号,年份 """初始化描述汽车的属性""" self.make=make self.model=mod 阅读全文
posted @ 2020-04-17 23:22 过气诗人 阅读(137) 评论(0) 推荐(0)
摘要: 每日一句:心如明镜台,时时勤拂拭 将函数存储在模块里 # pizza.py def make_pizza(size,*toppings): """概述要制作的披萨""" print("\nMaking a "+str(size)+"-inch pizza with the following top 阅读全文
posted @ 2020-04-16 22:50 过气诗人 阅读(144) 评论(0) 推荐(0)
摘要: 每日一句:沉思的人有一个目标,幻想的人却没有。 传递列表 def greet_users(names): """向列表中的每位用户都发出简单的问候""" for name in names: msg="Hello, "+name.title()+"!" print(msg) usernames=[' 阅读全文
posted @ 2020-04-15 22:55 过气诗人 阅读(223) 评论(0) 推荐(0)
摘要: 每日一句:理想即寻觅目标的思维。 函数 带名字的代码块,可以用于减少重复代码 # 1.定义函数def def great_user():# 指定函数名 """显示简单的问候语"""# 文档字符串的注释,用于描述该函数是干什么用的 print("Hello!!!")# 函数体 # 调用函数,执行函数代 阅读全文
posted @ 2020-04-14 22:37 过气诗人 阅读(159) 评论(0) 推荐(0)