之前都是直接输入打印结果的,这节课学习的是如何在代码运行时,由使用对象自行输入,打印出结果,这就是一个简单的交互。
方法input()
,生成的是字符串,如果需要使结果是数字用int(input())
print("How old are you?", end="")
age = input()
print("How tall are you?", end="")
height = input()
print("How much do you weigh", end="")
weight = input()
print(f"So you're {age} old, {height} tal28l and {weight} heavy.")