"""2.1 将一条消息存储到变量中,再将其打印出来"""
message = "I want to learn well in python."
print(message)
"""2.2 将一条消息存储到变量中,再将其打印出来;再将变量的值修改为一条新消息,并将其打印出来"""
message = "I want to learn well in python."
print(message)
message = "Python is a beautiful language."
print(message)
"""2.3 将用户的姓名存到一个变量中,并向该用户显示一条信息"""
name = "adson"
print("Hello " + name.title() + ", how do you feel today?")
"""2.4 将一个人名存储到一个变量中,再以小写、大写和首字母大写的方式显示这个人名"""
name = "adson"
print(name.upper())
print(name.lower())
print(name.title())
first_name = "thomas"
middle_name = "alva"
last_name = "edison"
full_name = first_name + ' ' + middle_name + ' ' + last_name
print(full_name.title() + ' once said, "Life itself, without the assistance of colleges and universities, is becoming an advanced institution of learning. "')
"""2.6 名人名言"""
famous_person = "thomas alva edison"
message = "Life itself, without the assistance of colleges and universities, is becoming an advanced institution of learning."
print(famous_person)
print(famous_person.lstrip())
print(famous_person.rstrip())
print(famous_person.strip())
"""2.8 数字8"""
print(4 + 4)
print(9 - 1)
print(2 * 4)
print(round(16 / 2))
"""2.9 最喜欢的数字"""
favorite_number = 8
print("My favorite number is " + str(favorite_number) + ".")
"""2.10 添加注释"""
print(4 + 4) #计算式子并输出
print(9 - 1)
print(2 * 4)
print(round(16 / 2))
favorite_number = 8 #赋值
print("My favorite number is " + str(favorite_number) + ".")
message = "I want to learn well in python."
print(message)
"""2.2 将一条消息存储到变量中,再将其打印出来;再将变量的值修改为一条新消息,并将其打印出来"""
message = "I want to learn well in python."
print(message)
message = "Python is a beautiful language."
print(message)
"""2.3 将用户的姓名存到一个变量中,并向该用户显示一条信息"""
name = "adson"
print("Hello " + name.title() + ", how do you feel today?")
"""2.4 将一个人名存储到一个变量中,再以小写、大写和首字母大写的方式显示这个人名"""
name = "adson"
print(name.upper())
print(name.lower())
print(name.title())
first_name = "thomas"
middle_name = "alva"
last_name = "edison"
full_name = first_name + ' ' + middle_name + ' ' + last_name
print(full_name.title() + ' once said, "Life itself, without the assistance of colleges and universities, is becoming an advanced institution of learning. "')
"""2.6 名人名言"""
famous_person = "thomas alva edison"
message = "Life itself, without the assistance of colleges and universities, is becoming an advanced institution of learning."
print(famous_person.title() + ' once said, "' + message + '"')
"""2.7 剔除人名中的空白"""
famous_person = " \tThomas Alva Edison \n"print(famous_person)
print(famous_person.lstrip())
print(famous_person.rstrip())
print(famous_person.strip())
"""2.8 数字8"""
print(4 + 4)
print(9 - 1)
print(2 * 4)
print(round(16 / 2))
"""2.9 最喜欢的数字"""
favorite_number = 8
print("My favorite number is " + str(favorite_number) + ".")
"""2.10 添加注释"""
print(4 + 4) #计算式子并输出
print(9 - 1)
print(2 * 4)
print(round(16 / 2))
favorite_number = 8 #赋值
print("My favorite number is " + str(favorite_number) + ".")
"""2.11 Python 之禅"""