- 博客(19)
- 收藏
- 关注
原创 高级编程技术作业_20 sklearn
题目:代码展示:from sklearn import datasets, cross_validation, metricsfrom sklearn.naive_bayes import GaussianNBfrom sklearn.svm import SVCfrom sklearn.ensemble import RandomForestClassifierdatas...
2018-06-20 00:41:03
179
原创 高级编程技术作业_19
%matplotlib inlineimport randomimport numpy as npimport scipy as spimport pandas as pdimport matplotlib.pyplot as pltimport seaborn as snsimport statsmodels.api as smimport statsmodels.form...
2018-06-08 18:38:10
275
原创 高级编程技术作业_18 scipy练习题
Exercise 10.1: Least squaresGenerate matrix A 2 Rmn with m > n. Also generate some vector b 2 Rm. Now nd x = arg minx kAx �� bk2. Print the norm of the residual.代码展示import numpy as npfro...
2018-06-05 21:25:21
488
原创 高级编程技术作业_17 matplotlib 练习题
Exercise 11.1: Plotting a functionPlot the functionf(x) = sin^2(x-2)e^-x2over the interval [0; 2]. Add proper axis labels, a title, etc. 代码展示:import matplotlib.pyplot as pltimport numpy as n...
2018-05-28 12:51:40
383
原创 高级编程技术作业_16 Numpy练习题
9.1输出结果: A = [[ 70.40406743 2.02668602 94.54645001 ... 110.30864041 125.31322128 119.79697459] [ 71.64816903 77.49512505 109.55139075 ... 78.44655339 158.64178009 134.17303738] [...
2018-05-20 16:28:12
315
原创 高级编程技术作业_15 leetcode练习题
14. Longest Common Prefix Write a function to find the longest common prefix string amongst an arrayof strings.If there is no common prefix, return an empty string "".Example 1: Input: [“flowe...
2018-05-02 00:11:56
133
原创 高级编程技术作业_14 leetcode练习题
152. Maximum Product Subarray Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.Example 1: Input: [2,3,-2...
2018-04-30 21:41:44
115
原创 高级编程技术作业_13 leetcode练习题
55.Jump GameGiven an array of non-negative integers, you are initially positioned atthe first index of the array.Each element in the array represents yourmaximum jump length at that position.Deter...
2018-04-30 14:59:50
98
原创 高级编程技术作业_11
10-4 访客名单题目描述:10-4 访客名单 :编写一个while 循环,提示用户输入其名字。用户输入其名字后,在屏幕上打印一句问候语,并将一条访问记录添加到文件guest_book.txt中。确保这个文件中的每条记录都独占一行。代码展示:filename = 'guest_book.txt'with open(filename, 'w') as file: wh...
2018-04-07 21:43:55
307
原创 高级编程技术作业_10
9-3 用户题目描述:创建一个名为USER的类,其中包含属性first_name和last_name。还有用户简介通常会存储的其他几个属性。在类USER中定义一个名为describe_user()的方法,它打印用户信息摘要;在定义一个名为greet_user()的方法,它向用户发出个性化问候。创建多个表示不同用户的实例,并对每个实例都调用上述两个方法。代码展示class U...
2018-04-05 18:33:10
223
原创 高级编程技术作业_9
8-3 T恤题目描述:编写一个名为make_shirt()的函数,它接受一个尺码以及要印到T恤上的字样。这个函数应打印一个句子,概要地说明T恤的尺码和字样。使用位置实参调用这个函数来制作意=一件T恤;再使用关键字实参来调用这个函数。代码展示def make_shirt(size, word): print("The T-shirt's size is " + siz...
2018-04-01 00:08:15
303
原创 高级编程技术作业_8
7-4 比萨配料 题目描述:编写一个循环,提示用户输入一系列的比萨配料,并在用户输入'quit'时结束循环。每当用户输入一种配料后,都打印一条消息,说我们会在比萨中添加这种配料。INPUT potato tomato fish quit OUTPUT Please input an ingredient We will put potato in pizza Plea...
2018-03-26 17:30:51
368
原创 高级编程技术作业_7
6-2 喜欢的数字 题目描述:使用一个字典来存储一些人喜欢的数字。请想5个人的名字,并将这些名字用作字典中的键;想出每个人喜欢的一个数字,并将这些数字作为值存储在字典中。打印每个人的名字和喜欢的数字。代码展示:dic = { 'Cirno': 9, 'Marisa': 13, 'Yukari': 8, 'Reimu' : 1000, ...
2018-03-25 12:06:01
575
原创 高级编程技术作业_6
5-2 条件测试题目描述:对于下面列出的各种测试,至少编写一个人结果为True或False的测试。 ·检查两个字符串是否相等。 ·使用函数lower的测试。 ·检查两个数字相等、不等、大于、小于、大于等于和小于等于。 ·使用关键字and和or的测试。 ·测试特定的值是否包含在列表中。 ·测试特定的值是否未包含在列表中。代码展示# 字符串相等与否print...
2018-03-25 11:15:51
194
原创 高级编程技术作业_5
4-3 数到20题目描述:使用一个for循环打印数字1~20(包含)代码展示for number in range(1,21): print(number)INPUT nullOUTPUT 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 204-6 奇数题目描述:通过...
2018-03-17 10:53:12
284
原创 高编技术作业_4
3-4 嘉宾名单题目描述:请创建一个列表,其中包含至少3个你想邀请的人;然后,使用这个列表打印消息,邀请这些人与你共进晚餐。代码展示:guests = {'Reimu', 'Marisa', 'Alice'}for guest in guests: print(guest + ", you are invited to dinner by Scarlet famli...
2018-03-15 11:37:56
260
原创 高级编程技术作业_2
本文是笔者对未来拥有坚实的Python编程基础之后的一个可能的展望 在拥有足够的编程能力的情况下,笔者愿意做一个竖版弹幕射击游戏,游戏规则概览如下:游戏共数关卡,关卡中敌机以固定模式从版面上方出现,玩家操纵机体在版面内移动,躲避子弹并向敌机射击。击破敌机将掉落点数,玩家所得分数随拾得点数时所处的高度递增。机体拥有初始固定残机,残机消耗至0则游戏结束;达到一定分数后可以增加残机。玩家拥有固定初始次...
2018-03-10 22:35:28
103
原创 高级编程技术作业_3
本文是《Python编程从入门到实践》第二章“变量和简单数据类型”的练习解答。2-1 简单消息题目描述:将一条消息存储到变量中,再将其打印出来。代码:message = "A message"print(message)2-2 多条简单消息题目描述:将一条消息存储到变量中,将其打印出来;再将变量的值修改为一条新消息,并将其打印出来。代码:me...
2018-03-10 22:00:48
259
原创 高级编程技术作业_1:浏览https://www.python.org的发现与收获
python是一门面向对象的解释型语言,其特点有: ①效率高,利用少量代码可执行大量工作 ②应用层面广泛,web程序、游戏编写、数据可视化等领域python都可涉足。 ③代码简洁,可读性强。初学python,可以通过官网对python进行详尽的了解,本博客旨在汇总python官网上一些有用的信息。1.python拥有有大量标准库,包括字符串处理(正则表达式、Uniode)、网络协议(HTTP...
2018-03-07 11:20:27
349
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人