“笨办法”学Python3,Zed A. Shaw, 习题4~5

代码

my_name = "YingXu"
my_age = 35
my_height = 165
my_weight = 63.7
my_eyes = 'Black'
my_teeth = 'White'
my_hair = 'Black'

print(f"Let's talk about {my_name}.")
print(f"He's {round(my_height/2.54)} inches tall.")
print(f"He's {round(my_weight/0.5435924)} pounds heavy.")
print("Actually that's not too heavy.")
print(f"He's got {my_eyes} eyes and {my_hair} hair.")
print(f"His teeth are actually {my_teeth} depending on the coffee")

total = my_age + my_height + my_weight
print(f"If I add {my_age}, {my_height}, and {my_weight} I get {total}.")

'''
如果想要在引号""中使用变量
必须要使用大括号{}
'''


遇到问题

没遇到问题

学到的

1、变量要用字母开头,所以阿拉伯数字不能作为变量;
2、{}内的内容,其实就是在“”内想使用变量时候的做法,避免python把变量当做字符。

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值