0% found this document useful (0 votes)
533 views6 pages

This study resource was: 1.1 参考资料 1.1 References

The document provides references for Python resources, including official download sites and recommended tutorials. It includes programming exercises focused on Python concepts such as file handling, recursion, and data analysis. Additionally, it outlines practice projects and quizzes to enhance programming skills.

Uploaded by

neel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
533 views6 pages

This study resource was: 1.1 参考资料 1.1 References

The document provides references for Python resources, including official download sites and recommended tutorials. It includes programming exercises focused on Python concepts such as file handling, recursion, and data analysis. Additionally, it outlines practice projects and quizzes to enhance programming skills.

Uploaded by

neel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1.

1 参考资料
1.1 References
1.几个常用的网站:
1. Several useful websites:
Python(x,y)的官方下载地址
Official download website of Python(x,y)
Python(x,y)的其他下载地址
Another download website of Python(x,y)
Python 官网
Official website of Python
或者也可以用现在很流行的 Python 科学计算环境,也是很多小伙伴(3xs)推荐的

m
Anaconda

e r as
Or, you may use the currently popular Python scientific calculation environment, which is

co
also recommended by many pals (3xs), i.e. Anaconda

eH w
Anaconda

o.
2.Python 参考教程 rs e
2. Reference Python courses
ou urc
(1) Magnus Lie Hetland,Beginning Python: from Novice to Professional, 2nd edition,
Apress.(第二版中译版名为《Python 基础教程》)
(2) Wesley Chun, Core Python Applications Programming, Prentice Hall.(第二版中译版名
o

为《Python 核心编程》)
aC s

(3) SciPy 科学计算:http://www.scipy.org/


v i y re

(4) Wes McKinney, Python for Data Analysis. 东南大学出版社. (英文影印本,中译版名


为《利用 Python 进行数据分析》)
(1) Magnus Lie Hetland, Beginning Python: from Novice to Professional, 2nd edition, Apress.
ed d

(2) Wesley Chun, Core Python Applications Programming, Prentice Hall.


ar stu

(3) SciPy scientific calculation:http://www.scipy.org/


(4) Wes McKinney, Python for Data Analysis. Southeast University Press (English photocopy)

1.2 编程和阅读程序小练习
sh is
Th

1.2 Quizzes of programming and program reading


试着写两个编程小练习题和读两个递归函数(不计分)。
Try to do two programming quizzes and read two recursive functions (no score)
1.编写一个输入分数,输出分数等级的程序,具体为:
1. Write a program for inputting fractional numbers and outputting grades of fractional numbers,
to be specific:
请添加必要的输入输出语句,尽量让程序友好。
Please add necessary input and output statements. Try your best to make the program friendly.
2.读一下以下递归函数 fun(),若 num 为-1234,则 fun(num)的输出结果是什么?
2. Please read the following recursive functions “fun()”. If “num” is -1234, what would the output
result of “fun(num)” be?

https://www.coursehero.com/file/21763652/%E5%8D%97%E5%A4%A7python%E8%AF%BE%E7%A8%8B/
3.写出程序的执行结果。
3. Please write down the operational result of program.
提示:在每一轮中“print n % 10,”语句都有可能被执行到,但是因为它前面的语句还没有
执行完,所以它不会马上输出结果
Tip: In each loop, the “print n % 10” statement may be executed, but it will not output the result
immediately since the statement before it has not been completely executed.
4. 编写一个找前 5 个默尼森数的程序。P 是素数且 M 也是素数,并且满足等式 M=2P(2 的
P 次方)-1,则称 M 为默尼森数。例如,P=5,M=2P(2 的 P 次方)-1=31,5 和 31 都是素
数,因此 31 是默尼森数。
4. Write a program for finding the first 5 Mersenne numbers. When P is a prime number and M is
also a prime number, and also when the equation M=2P (2 to the power of P) – 1 stands, then, M
is a Mersenne number. For example, P=5, M=2P (2 to the power of P)-1=31; both 5 and 31 are
prime numbers, so 31 is a Mersenne number.
程序输出结果为:

m
e r as
The output result of program is:

co
2.1 参考资料

eH w
o.
2.1 References
rs e
ou urc
1.关于正则表达式的资料(有兴趣的童鞋可以看一看)
1. Material about regular expressions (have a look if you have interest)
(1) 正则表达式的介绍,感谢 deerchao:
o

(1) Introduction to regular expressions. Thank deerchao:


aC s
v i y re

http://deerchao.net/tutorials/regex/regex.htm
(2) 正则表达式学习资料第二份:
(2) The second learning material on regular expressions:
http://www.java3z.com/cwbwebhome/article/article8/Regex/Java.Regex.Tutorial.html
ed d

2. Python 的 os 模块提供了执行文件和目录处理操作的函数,例如重命名和删除文件。
ar stu

2. The “os” module in Python provides functions for file execution and directory handling
operations, like file renaming and deletion.
要使用这个模块,你必须先导入它,然后才可以调用相关的各种功能。
sh is

For using this module, you must import it first and then call the relevant uses.
Th

importos
试一试以下的函数,理解它们的功能。
Try the following functions to understand their uses.
os.rename(current_file_name, new_file_name) #文件重命名
os.rename(current_file_name, new_file_name) # rename a file
os.remove(file_name) #删除文件
os.remove(file_name) # delete a file
os.mkdir(newdir) #创建目录
os.mkdir(newdir) # create a directory
os.chdir(newdir) #改变目录
os.chdir(newdir) # change a directory
os.getcwd() #获得当前路径

https://www.coursehero.com/file/21763652/%E5%8D%97%E5%A4%A7python%E8%AF%BE%E7%A8%8B/
os.getcwd() # acquire the current route
os.rmdir(dirname) #删除目录
os.rmdir(dirname) # delete a directory

2.1 编程小练习
2.1 Programming quiz
编程小练习(不计分)
Programming quiz (no score)
请完成以下文件综合编程迷你项目(提示:可以利用 list 的 insert 函数) 。
Please finish the following integrated mini-projects of file programming (tip: the
“insert” function in “list” can be used).
(1) 创建一个文件 Blowing in the wind.txt,其内容是:
(1) Create a file Blowing in the wind.txt, whose contents are:

m
e r as

co
(2) 在文件头部插入歌名“Blowin’ in the wind”

eH w
(2) Insert the song name “Blowin’ in the wind” into the file head.

o.
(3) 在歌名后插入歌手名“Bob Dylan”
rs e
(3) Insert the name of singer “Bob Dylan” after the song name.
ou urc
(4) 在文件末尾加上字符串“1962 by Warner Bros. Inc.”
(4) Add the string “1962 by Warner Bros. Inc.” to the end of file.
(5) 在屏幕上打印文件内容
o

(5) Print the file contents on the screen


aC s
v i y re

2.2 编程小练习
2.2 Programming quiz
ed d

熟悉并自行构造小例子测试序列类型函数和方法的使用(鼓励做更多函数或方法的使用尝
ar stu

试)。
Familiarize and construct examples to test sequences functions and methods(encourage
the use of more functions and methods).
sh is

(1)序列类型函数
Th

Functions of sequences type


(2)字符串类型方法
Methods of str
其中 translate()需要使用 maketrans()方法:
translate() needs the method of maketrans()
(3)列表类型方法
Methods of list

3.2 编程小练习
3.2 Programming quiz
编程题(不计分):

https://www.coursehero.com/file/21763652/%E5%8D%97%E5%A4%A7python%E8%AF%BE%E7%A8%8B/
Programming task (no score):
用字典创建一个平台的用户信息(包含用户名和密码)管理系统,新用户可以用与现有系统
帐号不冲突的用户名创建帐号,已存在的老用户则可以用用户名和密码登陆重返系统。建议
基本框架为:
Create a user information (including the user name and the password) management system for a
platform. The new user may create an account with a user name not in conflict with the existing
account in the system, and the existing old user may use the user name and the password to log in
to return to the system. The suggested basic framework is:

4.1 编程小练习
4.1 Programming quiz
编程小练习(不计分)

m
e r as
Programming quiz (no score)

co
求微软公司(MSFT)2015 年第一季度股票收盘价的平均值。

eH w
Calculate the average value of closing prices of Microsoft stock (MSFT) over the first quarter in

o.
2015. rs e
参考程序:
ou urc
Reference program:

参考结果:
o

Reference result:
aC s


v i y re

4.1 参考资料
ed d

4.1 References
ar stu

1.参考教材
1. Reference textbook
Wes McKinney, Python for Data Analysis: Data Wrangling with Pandas, NumPy, and IPython,
sh is

O'Reilly Media,2012.(中译版名为《利用 Python 进行数据分析》)


Th

Wes McKinney, Python for Data Analysis: Data Wrangling with Pandas, NumPy, and IPython,
O'Reilly Media,2012.

4.2 编程小练习
4.2 Programming quiz
1.编程小练习(不计分)
1. Programming quiz (no score)
图标题为“Max Close of
用折线图比较 Microsoft 和 Intel 在 2014 年每个月股票的最高收盘价。
MS and INTEL”,横坐标是时间,纵坐标是价格。结果参考如下图例。

https://www.coursehero.com/file/21763652/%E5%8D%97%E5%A4%A7python%E8%AF%BE%E7%A8%8B/
Use a line chart to compare the highest closing prices of stocks of Microsoft and Intel throughout
the year of 2014. The chart title is “Max Close of MS and INTEL”; the x axis shows the time and
the y axis shows the prices. The reference result is shown in the chart below.

参考程序:
Reference program:

4.2 小实践项目
4.2 Practice quiz
来个小小的小实践项目吧(此处不计分,但是其实在其他地方有计分哟)。
Well, let’s do a little practice quiz (no score is provided here, but scores are provided in other

m
places indeed).

e r as
计算 MovieLens 100k 数据集中男性女性用户评分的标准差并输出。

co
Calculate and output the standard deviation of males’ and females’ user scores in the data set

eH w
“MovieLens 100k”.

o.
数据集下载 http://files.grouplens.org/datasets/movielens/ml-100k.zip
rs e
Data set download: http://files.grouplens.org/datasets/movielens/ml-100k.zip
ou urc
其中 u.data 表示 100k 条评分记录,每一列的数值含义是:
Inside it, “u.data” represents 100k score records. The meaning of each column of value is:
user id | item id | rating | timestamp
o

u.user 表示用户的信息,每一列的数值含义是:
aC s

“u.user” represents the user information. The meaning of each column of value is:
v i y re

user id | age | gender | occupation | zip code


u.item 文件表示电影的相关信息,每一列的数值含义是:
The “u.item” file represents movie-related information. The meaning of each column of value is:
ed d


ar stu

可能会用到的相关函数:
Relevant functions for possible use:
更详尽的 API 文档请参考 http://pandas.pydata.org/pandas-docs/stable/ 。
sh is

For more detailed API documents, please go to


Th

http://pandas.pydata.org/pandas-docs/stable/.
只是示意
For information only

5.2 综合实践小项目
5.2 Comprehensive practice quiz
课程中的综合小项目,来挑战一下吧,跨过去你会有很大提升哟!
Challenge yourself to a comprehensive quiz in the course! You’ll have great progress after you
make it!
参考代码请见(能不看就不看哟):链接:
For the reference code, see (better not see it): link:

https://www.coursehero.com/file/21763652/%E5%8D%97%E5%A4%A7python%E8%AF%BE%E7%A8%8B/
链接: http://pan.baidu.com/s/1kTUw5En 密码:
Link: http://pan.baidu.com/s/1kTUw5En key: fjhm

m
e r as
co
eH w
o.
rs e
ou urc
o
aC s
v i y re
ed d
ar stu
sh is
Th

https://www.coursehero.com/file/21763652/%E5%8D%97%E5%A4%A7python%E8%AF%BE%E7%A8%8B/

Powered by TCPDF (www.tcpdf.org)

You might also like