程序设计基础
文章平均质量分 73
SDCS-16-WangHX
请登陆后查看
展开
-
程序设计实验Ⅰ期末模拟 解题报告
中山大学2016-2017学年程序设计Ⅰ期末模拟原创 2016-12-30 19:02:58 · 1885 阅读 · 7 评论 -
《Python编程:从入门到实践》课后练习9-1到9-14
9-1创建一个名为Restaurant 的类,其方法init() 设置两个属性:restaurant_name 和cuisine_type 。创建一个名为describe_restaurant() 的方法和一个名为open_restaurant() 的方法,其中前者打印前述两项信息,而后者打印一条消息,指出餐馆正在营业。class Restaurant(): def __init__(sel原创 2018-04-10 11:13:52 · 3085 阅读 · 1 评论 -
《Python编程:从入门到实践》课后练习10-1到10-12
10-1在文本编辑器中新建一个文件,写几句话来总结一下你至此学到的Python知识,其中每一行都以“In Python you can”打头。将这个文件命名为learning_python.txt,并将其存储到为完成本章练习而编写的程序所在的目录中。编写一个程序,它读取这个文件,并将你所写的内容打印三次:第一次打印时读取整个文件;第二次打印时遍历文件对象;第三次打印时将各行存储在一个列表中,再在wi原创 2018-04-10 11:42:50 · 2103 阅读 · 0 评论 -
《Python编程:从入门到实践》课后练习11-1到11-3
11-1编写一个函数,它接受两个形参:一个城市名和一个国家名。这个函数返回一个格式为City, Country 的字符串,如Santiago, Chile 。将这个函数存储在一个名为city_functions.py的模块中。 创建一个名为test_cities.py的程序,对刚编写的函数进行测试(别忘了,你需要导入模块unittest 以及要测试的函数)。编写一个名为test_city_coun原创 2018-04-16 15:20:35 · 980 阅读 · 0 评论 -
Leetcode三题:#62、#78、#89
#62 Unique Paths题目描述A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below). The robot can only move either down or right at any point in time. The robot is try原创 2018-05-02 16:55:09 · 171 阅读 · 0 评论 -
Leetcode三题:#120、#55、#134
#120 Triangle题目描述Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2]...原创 2018-05-13 19:02:51 · 159 阅读 · 0 评论 -
Python Numpy习题
Generate matrices A, with random Gaussian entries, B, a Toeplitz matrix, where A ∈ R(n×m) and B ∈ R(m×m), for n = 200, m = 500.import numpyimport scipy.linalgn = 200m = 500Mu = 0Sigma = 1A...原创 2018-05-22 23:42:42 · 614 阅读 · 0 评论 -
Python Matplotlib习题
Exercise 11.1: Plotting a functionPlot the function f(x)=sin2(x−2)e−x2f(x)=sin2(x−2)e−x2f(x) = sin^2(x-2){e^{-x^2}} over the interval [0, 2]. Add proper axis labels, a title, etc.代码:import numpy...原创 2018-05-28 10:11:34 · 1245 阅读 · 0 评论 -
Python 对Anscombe四组数据的分析
Part 1For each of the four datasets…Compute the mean and variance of both x and yCompute the correlation coefficient between x and yCompute the linear regression line: y=β0+β1x+ϵy=β0+β1x+ϵy = \...原创 2018-06-13 15:01:00 · 2797 阅读 · 0 评论 -
Python Sklearn习题
题目In the Second ML assignment you have to compare the performance of three different classification algorithms, namely Naive Bayes, SVM, and Random Forest. For this assignment you need to generate...原创 2018-06-21 17:35:43 · 414 阅读 · 0 评论 -
《Python编程:从入门到实践》课后练习8-1到8-14
8-1编写一个名为display_message() 的函数,它打印一个句子,指出你在本章学的是什么。调用这个函数,确认显示的消息正确无误。def display_message(): print('I learn function in Chapter 8.')if __name__ == "__main__": display_message()8-2编写一个名为favorite原创 2018-04-01 18:53:16 · 2987 阅读 · 6 评论 -
《Python编程:从入门到实践》课后练习7-1到7-10
7-1编写一个程序,询问用户要租赁什么样的汽车,并打印一条消息,如“Let me see if I can find you a Subaru”。car = input('Which car do you like?')print('Let me see if I can find you a ' + car + '.')7-2编写一个程序,询问用户有多少人用餐。如果超过8人,就打印一条消息,指出原创 2018-04-01 18:13:37 · 1712 阅读 · 0 评论 -
16计科程设考试压轴题 解题报告
【题目大意】有5个人,每人有10个粉丝,现在要从中选出K个人,记这K人拥有的粉丝数为N,求出一种选法使得(N-7*K)最大。原创 2017-01-04 19:12:10 · 660 阅读 · 0 评论 -
期中模拟考试 题解
理论部分实验部分A Copy ConstructorB A Static FunctionC A Class with Dual RoleD String edenE Student原创 2017-05-08 10:26:38 · 790 阅读 · 2 评论 -
程设期中理论题解析
2017·程设期中理论题解析原创 2017-05-17 19:36:37 · 754 阅读 · 1 评论 -
《Python编程:从入门到实践》课后练习4-1到4-15
4-1想出至少三种你喜欢的比萨,将其名称存储在一个列表中,再使用for循环将每种比萨的名称都打印出来。修改这个for循环,使其打印包含比萨名称的句子,而不仅仅是比萨的名称。对于每种比萨,都显示一行输出,如“I like pepperoni pizza”。在程序末尾添加一行代码,它不在for循环中,指出你有多喜欢比萨。输出应包含针对每种比萨的消息,还有一个总结性句子,如“I really...原创 2018-03-14 20:13:51 · 1367 阅读 · 0 评论 -
《Python编程:从入门到实践》课后练习2-1到2-11
2-1将一条消息存储到变量中,再将其打印出来。message = 'Hello world!'print(message)2-2将一条消息存储到变量中,将其打印出来;再将变量的值修改为一条新消息,并将其打印出来。message = 'Hello world!'print(message)message = 'Hello python!'print(messa...原创 2018-03-11 22:47:56 · 490 阅读 · 0 评论 -
浏览python.org后的发现与收获 和 希望实现的python程序
进入python.org,首先看到的是一个python在线编程的窗体。继续浏览,发现菜单栏中提供了python简介、python下载、python社区等多个选项,点击Downloads,找到了python从2.0.1到3.6.4多个历史版本的安装包,并且对于Windows、Linux、Mac OS X等多种操作系统都有对应的版本。在Documentation选项中,找到了有关python的十分详细的原创 2018-03-12 00:01:10 · 501 阅读 · 0 评论 -
《Python编程:从入门到实践》课后练习3-1到3-11
3-1将一些朋友的姓名存储在一个列表中,并将其命名为names 。依次访问该列表中的每个元素,从而将每个朋友的姓名都打印出来。names = ['Leo', 'Jack', 'Lily', 'Evie', 'Jack']for name in names: print(name)3-2继续使用练习3-1中的列表,但不打印每个朋友的姓名,而为每人打印一条消息。每条消息都包含相同的问候语,但抬原创 2018-03-14 15:55:32 · 1116 阅读 · 0 评论 -
《Python编程:从入门到实践》课后练习5-1到5-11
5-1编写一系列条件测试;将每个测试以及你对其结果的预测和实际结果都打印出来。你编写的代码应类似于下面这样:car = 'subaru'print("Is car == 'subaru'? I predict True.")print(car == 'subaru') print("\nIs car == 'audi'? I predict False.")print(car == 'au原创 2018-03-21 17:31:01 · 3671 阅读 · 3 评论 -
《Python编程:从入门到实践》课后练习6-1到6-11
6-1使用一个字典来存储一个熟人的信息,包括名、姓、年龄和居住的城市。该字典应包含键first_name 、last_name 、age 和city 。将存储在该字典中的每项信息都打印出来。people = {'first_name' : 'San', 'last_name' : 'Zhang', 'age' : 17, 'city' : 'Guangzhou'}for key, value in原创 2018-03-26 09:45:10 · 3062 阅读 · 0 评论 -
Python Scipy习题
Exercise 10.1: Least squaresGenerate matrix A∈Rm∗nA∈Rm∗nA∈R^{m*n} with m>nm>nm > n. Also generate some vector b∈Rmb∈Rmb∈ R^m. Now find x=argminx||Ax−b||2x=argminx||Ax−b||2x = arg \min_x||Ax ...原创 2018-06-07 09:50:49 · 472 阅读 · 0 评论