第二章作业

"""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())


"""2.5 名人名言"""
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 之禅"""


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值