代码:
# 2.1
print("2.1")
str1 = "Python is interesting."
print(str1)
#2.2
print("2.2")
str2 = "Python is interesting."
print(str2)
str2 = "C++ is interesting."
print(str2)
#2.3
print("2.3")
str3 = "Tom"
print("Good morning, "+str3+".")
#2.4
print("2.4")
str4 = "JaCK"
print(str4.lower())
print(str4.upper())
print(str4.title())
#2.5
print("2.5")
str5 = 'Hazlitt once said, "Easy come, easy go."'
print(str5)
#2.6
print("2.6")
famous_person = 'Hazlitt'
message = famous_person + ' once said, "Easy come, easy go."'
print(message)
#2.7
print("2.7")
str7 = "\t\tAlicia\t\n"
print(str7.lstrip())
print(str7.rstrip())
print(str7.strip())
#2.8
print("2.8")
print(2+6)
print(10-2)
print(8*1)
print(int(16/2))
#2.9
print("2.9")
num9 = 9
str9 = str(num9) + " is my favourite number."
print(str9)
#2.10
#The file is finish on 2018.3.8
#2.11
print("2.11")
import this
输出:
2.1
Python is interesting.
2.2
Python is interesting.
C++ is interesting.
2.3
Good morning, Tom.
2.4
jack
JACK
Jack
2.5
Hazlitt once said, "Easy come, easy go."
2.6
Hazlitt once said, "Easy come, easy go."
2.7
Alicia
Alicia
Alicia
2.8
8
8
8
8
2.9
9 is my favourite number.
2.11
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!