Description
Select from exercise 2-1 to 2-11.
I will finish the code with comment about the requirement.
Code
2-3
1 | # 2-3 个性化消息: 将用户的姓名存到一个变量中, |
result:
D:\pyproject\homework1\venv\Scripts\python.exe D:/pyproject/homework1/2_3.py
Jobs
Hello Jobs, would you like to learn some Python today?
Process finished with exit code 0
2-4
1 | # 2-4 调整名字的大小写: 将一个人名存储到一个变量中, |
result:
D:\pyproject\homework1\venv\Scripts\python.exe D:/pyproject/homework1/2_4.py
sKy raKeR
SKY RAKER
sky raker
Sky Raker
Process finished with exit code 0
2-7
1 | # 2-7 剔除人名中的空白: 存储一个人名, |
result:
D:\pyproject\homework1\venv\Scripts\python.exe D:/pyproject/homework1/2_7.py
-------------
Sky Raker
-------------
Sky Raker
-------------
Sky Raker
-------------
Sky Raker
-------------
Process finished with exit code 0
2-8
1 | # 2-8 数字8: 编写4个表达式,它们分别使用 |
result:
D:\pyproject\homework1\venv\Scripts\python.exe D:/pyproject/homework1/2_8.py
8
8
8
8.0
Process finished with exit code 0
2-11
1 | # 2-11 Python之禅: 在Python终端会话中执行命令import this , |
result:
D:\pyproject\homework1\venv\Scripts\python.exe D:/pyproject/homework1/2_11.py
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!
Process finished with exit code 0