8-1
def display_message(subject):
print("I have learned "+subject+"!")
subjects=["Unit 1","Unit 2","Unit 3","Unit 4","Unit 5"]
for subject in subjects:
display_message(subject)8-2
def favorite_book(title):
print("One of my favorite book is "+title+".")
favorite_book("Alice in Wonderland")8-3
def make_shirt(size,symbol):
print("The size of the shirt is "+str(size)+",")
print("and the symbol on the shirt is "+symbol+".")
make_shirt(175,"Fangyuan")
make_shirt(symbol="Fangyuan",size=175)
本文通过三个具体例子展示了Python中函数的定义及使用方式。包括显示学习主题、推荐喜爱书籍及定制文化衫的过程。
896

被折叠的 条评论
为什么被折叠?



