《“笨办法”学python3》Ex 5

知识点:

EX5是打印和变量的更多练习,其中整数转浮点数只用在在运算中加入浮点数计算,比如 5 * 5.0 = 25.0

程序:

my_name = 'Ping X'
my_age = 23 # not a lie
my_height = 161 # cm
my_weight = 51.5 # kg
my_eyes = 'Brown'
my_teeth = 'White'
my_hair = 'Black'

print(f"Let's talk about {my_name}. ")
print(f"She's {my_height} cm tall. ")
print(f"She's {my_weight} kg heavy. ")
print("Acturally that's not too heavy. ")
print(f"She's got {my_eyes} eyes and {my_hair} hair.")
print(f"Her teeth are usually {my_teeth} depending on the coffee. ")

# this line is tricky, try to get it excatly right
total = my_age + my_height + my_weight
print(f"If I add {my_age}, {my_weight}, and {my_weight} I get {total}. ")

输出:

PS C:\Users\xue weiruan\github> python ex5.py
Let's talk about Ping X.
She's 161 cm tall.
She's 51.5 kg heavy.
Acturally that's not too heavy.
She's got Brown eyes and Black hair.
Her teeth are usually White depending on the coffee.
If I add 23, 51.5, and 51.5 I get 235.5.
PS C:\Users\xue weiruan\github>

 

你可能感兴趣的:(Python)