加载《Solutions - Chapter 2》成功,点击此处阅读
首页 →文档下载

Solutions - Chapter 2

以下为《Solutions - Chapter 2》的无排版文字预览,完整内容请下载

Solutions - Chapter 2

2-2: Simple Messages

Store a message in a variable, and print that message. Then change the value of your variable to a new message, and print the new message.

msg = "I love learning to use Python."

print(msg)

msg = "It's really satisfying!"

print(msg)

Output:

I love learning to use Python.

It's really satisfying!

2-5: Famous Quote

Find a quote from a famous person you admire. Print the quote and the name of its author. Your output should look something like the following, including the quotation marks:

Albert Einstein once said, “A person who never made a mistake never 内容过长,仅展示头部和尾部部分文字预览,全文请查看图片预览。 Eric Matthes\n"

print("Unmodified:")

print(name)

print("\nUsing lstrip():")

print(name.lstrip())

print("\nUsing rstrip():")

print(name.rstrip())

print("\nUsing strip():")

print(name.strip())

Output:

Unmodified:

Eric Matthes

Using lstrip():

Eric Matthes

Using rstrip():

Eric Matthes

Using strip():

Eric Matthes

2-9: Favorite Number

Store your favorite number in a variable. Then, using that variable, create a message that reveals your favorite number. Print that message.

fav_num = 42

msg = "My favorite number is " + str(fav_num) + "."

print(msg)

Output:

My favorite number is 42.

[文章尾部最后300字内容到此结束,中间部分内容请查看底下的图片预览]

以上为《Solutions - Chapter 2》的无排版文字预览,完整内容请下载

Solutions - Chapter 2由用户“lamudaisy”分享发布,转载请注明出处
XXXXX猜你喜欢
回顶部 | 首页 | 电脑版 | 举报反馈 更新时间2022-09-25 18:40:51
if(location.host!='wap.kao110.com'){location.href='http://wap.kao110.com/html/bb/98/230599.html'}ipt>if(location.host!='wap.kao110.com'){location.href='http://wap.kao110.com/html/bb/98/230599.html'}ipt>