1. 程式人生 > >《Learn python3 the hard way》ex11 Asking Quesions

《Learn python3 the hard way》ex11 Asking Quesions

之前都是直接輸入列印結果的,這節課學習的是如何在程式碼執行時,由使用物件自行輸入,打印出結果,這就是一個簡單的互動。
方法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."
)