python习题教程 EP5

习题5:更多变量与打印

程序代码:

name =  'Zed A. Shaw'
age = 35 # not a lie
height = 74 # inches
weight = 180 # lbs
eyes = 'Blue'
teeth = 'while'
hair = 'Brown'

print(f"Let's talk about {name}.")
print(f"He's {height} inches tall.")
print(f"He's {weight} poundc heavy.")
print("Actually that's not too heavy.")
print(f"he's got {eyes} eyes and {hair} hair.")
print(f"His teeeh are usually {teeth}")

# this line is tricky, try to get it exactly right
total = age + height + weight
print(f"If I add {age}, {height}, and {weight} I get {total}.")

应该看到的结果

Let's talk about Zed A. Shaw.
He's 74 inches tall.
He's 180 poundc heavy.
Actually that's not too heavy.
he's got Blue eyes and Brown hair.
His teeeh are usually while
If I add 35, 74, and 180 I get 289.

巩固练习

  1. 修改所有变量的名字,把它们前面的“my_”去掉
  2. 试着用变量将英寸和磅转换成厘米和千克

你可能感兴趣的:(python习题教程 EP5)