#结尾的end = ' ',为了Python不换行。
print("How old are you?", end=' ')
age = input() #age变量等于输入的值
print("How tall are you?", end = ' ')
height = input() #同age
print("How much do you weigh?", end = ' ')
weight = input() #同age
print(f"So, you're {age} old, {height} tall and {weight} heavy.") #f将变量字符串化
How old are you?
38 #输入的值,也可以是别的数字。
How tall are you?
6'2" #同上
How much do you weigh?
180lbs #同上
So, you're 38 old, 6'2" tall and 180lbs heavy.
x = input("name:") #input()函数也可以输入文字的
print(x)
x = int(input())
print(x*2)
输出:
name:lily #输入lily
lily
4 #输入4,被转化为数值
8
print("Where are you from?", end = " ")
country = input()
print("What do you do?",end = " ")
work = input()
print(f"I'm from {country} and I'm a {work}.")
输出
Where are you from?
China
What do you do?
Engineer
I'm from China and I'm a Engineer.