Python编程入门到实践Chapter-02

"""
Exercise 2-2:
多条简单消息

"""

msg = "I love python!"
print(msg)

msg = "I love myself!"
print(msg)
"""
Exercise 2-3:
个性化消息

"""
name = "Dylan"
print("Hello %s, would you like to learn some Python today?" %name)
"""
Exercise 2-4:
调整名字大小写

"""
name = "dylan smith"
print(name.title())
print(name.upper())
print(name.lower())


"""
Exercise 2-5:
名言

"""

print("Albert Einstein once said, ", end='')
print("A person who never made mistake never tried anything new.")
"""
Exercise 2-6:
名言2

"""
famous_person = 'albert einstein'
print("%s once said, " %famous_person.title(), end='')
print("A person who never made mistake never tried anything new.")
"""
Exercise 2-7:
剔除人名中的空白

"""

name = '\tdylan smith   '
print(name.rstrip())
print(name.lstrip())
print(name.strip())
"""
Exercise 2-8:
数字8

"""

print(8+8)
print(9-55)
print(9/4)
print(9*6)
"""
Exercise 2-9:
最喜欢的数字

"""

num = 1
print("My favorite number is %d" %num)
"""
Exercise 2-10:
添加注释

"""

# /*-----------------------------------------------------
# 版权所有 @Copyright Dylan Smith
#
# 文件名:课后练习题
# 文件功能描述:习题源代码
# author:Dylan Smith
# 时间:2018-12-12
# 创建标识:NULL
#
# 修改标识:NULL
#
# 修改描述:NULL
# -----------------------------------------------------*/

猜你喜欢

转载自blog.csdn.net/weixin_41526797/article/details/84971482