笨办法学Python3 习题11-12 提问 提示别人
1 print("How old are you?",end=" ") # end=" "下一行结果空格后粘贴在同一行
2 age = input() # 需要用户输入年龄值赋给 age 变量 // input(Y)函数,作用让用户输入值,括号内的内容先会弹出来,后面位置让用户输入
3 print("age =",repr(age)) # 打印 age = (用户输入的年龄值) // repr(X)函数把值转换成字符串
4
5 print("How tall are you?",end=" ") # 打印 你多高?下一行空一格不换行
6 height = input() # 需要用户输入身高值
7 print("height=",repr(height)) # 打印 heighe= (用户已输入的身高值)
8
9 print("How much do you weight?",end=" ") # 打印 你多重? 下一行空一格不换行
10 weight =input() # 需要用户输入体重值
11 print("weight=",repr(weight)) # 打印 weight= (用户已输入的体重值)
12
13 print(f"So, you're {age} old, {height} tall and {weight} heavy.")
14 print("So, you're {} old, {} tall and {} heavy.".format(age,height,weight)) #另外一种格式化写法
15
16 age = input("How old are you? ") # 电脑系统运行顺序是,先运行弹出()内的内容,再要求用户输入值,最后赋值给变量 age
17 height =input("How tall are you? ") # 用在需要先系统弹出内容,然后用户需要输入值的时候用
18 weight = input("How much do you weight? ")
19 print("So, you're {} old, {} tall and {} heavy.".format(age,height,weight))
20 print(f"So, you're {age} old, {height} tall and {weight} heavy.")
21
22 na_me = input(f"You are {age} old,What's your name? " ) # input()里面也可加格式化函数
23 print("Hello ! nace to meet you!", na_me) # 三类打印写法
24 print(f"Hello ! nace to meet you! {na_me}")
25 print("Hello ! nace to meet you! {}".format(na_me))
PS C:\Users\Administrator> cd lpthw
PS C:\Users\Administrator\lpthw> python ex11.py
How old are you? 25
age = '25'
How tall are you? 164
height= '164'
How much do you weight? 52
weight= '52'
So, you're 25 old, 164 tall and 52 heavy.
So, you're 25 old, 164 tall and 52 heavy.
How old are you? 25
How tall are you? 164
How much do you weight? 53
So, you're 25 old, 164 tall and 53 heavy.
So, you're 25 old, 164 tall and 53 heavy.
You are 25 old,What's your name? biandou
Hello ! nace to meet you! biandou
Hello ! nace to meet you! biandou
Hello ! nace to meet you! biandou