- 博客(12)
- 收藏
- 关注
原创 《python编程从入门到实践》第15章 生成数据 - 动手试一试
15-1 & 15-2#15-1立方"""前5个整数"""import matplotlib.pyplot as plt#折线plt.title("pic", fontsize = 20)plt.xlabel("x", fontsize = 15)plt.ylabel("y", fontsize = 15)x_value = [1,2,3,4,5]y_valu...
2020-02-12 22:17:07
473
1
原创 《python编程从入门到实践》第11章 测试代码(练习)
P192#11-1#city_functions.pydef place(city,country): """生成城市和国家""" full_name = city+', '+country return full_name.title()import unittestfrom city_functions import placeclass Tes...
2020-01-29 14:15:09
178
原创 《python编程从入门到实践》第10章 文件和异常(练习)
本章需要对python报错(异常)进行处理,常见异常提示见上一个博,供参考。P169#10-1filename = 'learning_python.txt'with open(filename) as file_object: python = file_object.read() print(python)#.rstrip()消除换行符with open(...
2020-01-28 21:52:40
307
原创 python 中常见报错类型
BaseException 所有异常的基类 SystemExit 解释器请求退出 KeyboardInterrupt 用户中断执行(通常是输入^C) Exception 常规错误的基类 StopIteration 迭代器没有更多的值 GeneratorExit 生成器(generator)发生异常来通知退出 StandardError 所有的内建标准异常的基类...
2020-01-28 18:52:27
523
原创 《python编程从入门到实践》1~5章 练习
补一篇博,书中前几章的练习题,有一些作业写在一起没加注释,不足之处望多加指正。第1章 起步message="Hello Python world!"print(message)message="HELLO PYTHON CRASH COURSE WORLD!"print(message)第2章 变量和简单数据类型P23作业name="Eric"print("Hel...
2020-01-27 13:54:23
334
原创 《python编程从入门到实践》第9章 类(练习)
P142#9-1class Restaurant(): def __init__(self,restaurant_name,cuisine_type): #初始化属性 self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type ...
2020-01-27 13:29:18
192
原创 《python编程从入门到实践》第8章 函数(练习)
P116作业#8-1def display_message(): print('在本章学习函数') display_message()#8-2print('')def favorite_book(title): print('One of my favorite book is '+title.title()+'.') favorite_book...
2020-01-25 15:33:19
309
1
原创 《python编程从入门到实践》第7章 用户输入和while循环(练习)
如题:7-1汽车租赁:编写一个程序,询问用户要租赁什么样的汽车,并打印一条消息,如“Let me see if I can find you a Subaru.”7-2餐馆定位:编写一个程序,询问用户有多少人用餐。如果超过8人,就打印一条消息,指出没有空桌;否则指出有空桌。7-3 10的整数倍:让用户输入一个数字,并指出这个数字是否是10的整数倍。7-4 比萨配料:编写一个循环,...
2020-01-19 17:42:08
339
原创 《python编程从入门到实践》第6章 字典(练习)
使用字典并打印#6-1jz = { 'first_name':'han', 'last_name':'jiaoyang', 'age':22, 'city':'changchun', }print(jz)#6-2numbers={ 'a':1, 'b':2, 'c':3, 'd':4, 'e':5, ...
2020-01-18 19:38:46
259
原创 吴恩达机器学习作业——K-means聚类
将K-means算法用于图片压缩(减少颜色数量,只保留最普遍的颜色)1.练习K-means(找到最近的聚类中心)X样本数300*2,找到离前三个样本距离最近的聚类中心(三个),并标明位置(第几个聚类中心离样本最近)fprintf('Finding closest centroids.\n\n');K = 3; % 3 Centroidsinitial_centroids = ...
2019-09-07 23:34:38
1697
原创 吴恩达机器学习作业——正则化线性回归及偏差和方差
自变量x——水库中水量变化;因变量y——水坝外水流量。任务:1.预测 2.诊断算法错误。训练集:X,y交叉集:Xval,yval测试集:Xtest,ytest1显示图像fprintf('Loading and Visualizing Data ...\n')load ('ex5data1.mat');m = size(X, 1);plot(X, y, 'rx', ...
2019-08-04 14:08:40
548
原创 吴恩达机器学习作业——多元分类及神经网络
第四周作业多元分类问题:识别手写数字0~9(0替换为10),5000个样本,20*20共400像素。多元分类Logistic回归1参数初始化%% Initializationclear ; close all; clc%% Setup the parameters you will use for this part of the exerciseinput_layer_...
2019-08-01 00:17:47
622
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人