2-5 名言: 找一句你钦佩的名人说的名言, 将这个名人的姓名和他的名言打印出来。 输出应类似于下面这样(包括引号) :* Albert Einstein once said, “A person who never made a mistake never tried anything new.”*
# 2-1
message = 'Hello world'print(message)
# 2-2
message = 'Make American great again!'print(message)
# 2-3
name = 'Wayne Mai'print('Have a sweet dream, ' + name)
# 2-4print(name.upper())
print(name.lower())
print(name.title())
# 2-5 & 2-6
famous_person = 'helen keller'
message = 'The best and most beautiful things in the world cannot be seen or even touched \
- they must be felt with the heart.'print(famous_person.title() + ' once said: "' + message + '"')
# 2-7
famous_person = '\t' + famous_person + '\n'print(famous_person)
print(famous_person.lstrip())
print(famous_person.rstrip())
print(famous_person.lstrip())
# 2-8print(4 + 4)
print(4 - (-4))
print(4 * 2)
print(int(4 / (1 / 2)))
# 2-9
lucky_number = 4print("Wouldn't number %d be lovely?" % lucky_number)
# 2-10# As you can see, all the comments are shown above.# 2-11
import this
输出如下:
Hello world
Make American great again!
Have a sweet dream, Wayne Mai
WAYNE MAI
wayne mai
Wayne Mai
Helen Keller once said: "The best and most beautiful things in the world cannot be seen or even touched - they must be felt with the heart."
helen keller
helen keller
helen keller
helen keller
8
8
8
8
Wouldn't number 4 be lovely?
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