【笨方法学python】ex5 - 更多的变量和打印

代码如下:

点击查看代码
# -*-coding:utf-8- -*-
# 更多的变量和打印

my_name = 'P.S'
my_age = 28
my_height = 183 # cm
my_weight = 100 # kg
my_eyes = 'Black'
my_teeth = 'White'
my_hair = 'Black'

# print "Let's talk about %s." % my_name
# print "He's %d cm tall." % my_height
# print "He's %d kg 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 the 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 + my_weight)

# 中文
print "让我们说一下 %s。" % my_name
print "他的身高是 %d cm。" % my_height
print "他有 %d 公斤重" % my_weight
print "实际上并不是很重。"
print "他有 %s 色的眼睛和 %s 色的头发。" % (my_eyes, my_hair)
print "由于经常喝咖啡,他的牙齿是 %s 色的。" % my_teeth

# this line is tricky, try to get it exactly right
print "如果我把年龄 %d, 身高 %d,体重 %d 相加,我将得到 %d 。" % (my_age, my_height, my_weight,my_age + my_height + my_weight)

执行结果:
image

posted @ 2022-10-05 03:43  TiramisuPS  阅读(19)  评论(0编辑  收藏  举报