Advanced Computer Programming, Homework, week 1
1.浏览Python主页(https://www.python.org/),在博客上写下你有哪些发现和收获
I visited Python’s homepage one year ago, but I just downloaded the installation package at that time.
At this time, I find some key messages below.
Looking at the picture above, we may have a general knowledge of the usages of Python. I have used some packages in the first three parts, such as tkInter, PyQt, SciPy, Pandas and so forth.
Python have a lot of packages, it’s impossible to be familiar with every package. Learning of the packages which we need is enough. For instance, now I’m major in the machine learning and data mining, so I choose Anaconda, which consists of many scientific computation packages.
此外,官网还给出了文档和交流社区,这些对于初学者来说都是不错的学习资源
学会看官方文档非常重要,因为Python有各种各样的Package,Package最好的学习途径便是官方文档
2.假设你已经成为一名Python编程高手,你打算实现怎样的程序?在博客上写下你的目标
If I become a Python programming master, I will do the things below,
- Data Mining
- Machine Learning
- Web Development
- Simple Game
- …
I have wrote some programs about the first three, but I haven’t used Python to write a game.
3.教材中课后的练习,2-1到2-11,选一些写到你的博客上
以下代码通过 Jupyter notebook 导出Markdown源码
# 2-1 简单消息
变量 = '消息'
print(变量)
消息
# 2-2 多条简单消息
变量 = 'new message'
print(变量)
new message
# 2-3 个性化消息
name = 'Eric'
print('Hello', name + ', would you like to learn some Python today?')
Hello Eric, would you like to learn some Python today?
# 2-4 调整名字的大小写
name = 'Geass Taiga'
print(name.lower())
print(name.upper())
print(name.title())
geass taiga
GEASS TAIGA
Geass Taiga
# 2-5 名言
print('Albert Einstein once said, "A person who never made a mistake never tried anything new."')
Albert Einstein once said, "A person who never made a mistake never tried anything new."
# 2-6 名言2
famous_person = 'Albert Einstein'
message = 'A person who never made a mistake never tried anything new.'
print(famous_person, 'once said, "' + message + '"')
Albert Einstein once said, "A person who never made a mistake never tried anything new."
# 2-7 删除人名中的空白
name = " Geass Taiga \n\t "
print(name)
print(name.lstrip())
print(name.rstrip())
print(name.strip())
Geass Taiga
Geass Taiga
Geass Taiga
Geass Taiga
# 2-8 数字8
print(1+7)
print(9-1)
print(2*4)
print(16//2)
8
8
8
8
# 2-9 最喜欢的数字
num = 4
print("My favorite number is: ", num)
My favorite number is: 4
# 2-10 添加注释
# 输出列表
[x**2 for x in range(6)]
[0, 1, 4, 9, 16, 25]
# 2-11 Python之禅
import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!