《笨办法学Python》——习题5

本文介绍了《笨办法学Python》习题5的解答,包括完成基本习题,如变量名修改,以及加分习题,如使用不同格式化字符,特别是%r的运用。此外,还探讨了Python格式化字符的搜索和数值类型的转换实践。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


系统:mac os 10.14
Python: 2.7.10
版本:《笨办法学Python》(第四版)

基本习题

1. 完成基本习题

(1) 根据题目,编辑以下内容:
附代码:

my_name = 'Zed A. Shaw'
my_age = 35 # not a line
my_height = 74 # inches
my_weight = 180 # labs
my_eyes = 'Blue' 
my_teeth = 'White'
my_hair = 'Brown'

print "Let's talk about %s." % my_name
print "He's %d inches tall." % my_height
print "He's %d pounds heavy." % my_weight
print "Actually that's not too heavy."
print "He's got %s eyes and %s hair." % (my_eyes, my_hair)
print "His teeth are usually %s depending on tne coffee." % my_teeth

# this line is tricky, try to get it exactly right

print "If I add %d, %d, and %d I get %d." % (my_age, my_height, my_weight, my_age + my_height + 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值