习题11 提问

print("How old are you?", end=' ')                     # How old are you? 45
age = input()
print("How tall are you?", end='')                     # How tall are you? 173
height = input()
print("How much do you weight?", end='')               # How much do you weight? 80
weight = input()

print(f"So, you're {age} old, {height} tall and {weight} heavy.")  # so,you're 45 old, 173 tall and 80 weight.

"""
换一种写法:
age = input("How old are you?",)                        # 强迫症犯了,为什么有下划线,为什么抄一遍就没有
age = input("How old are you?",)
height = input("How tall are you?",)
weight = input("How much do you weight?",)
print(f"So, you're {age} old, {height} tall and {weight} heavy.")

"""
"""
input()
1、有问有答,终端区输入
2、函数好用,赋值第一,必须赋值
3、input的提示信息也是输出
4、输入类型必为str,数字需要转换类型int or float
"""
print(age+height+weight)    # 所以,输入42、160、80运行结果为4216080,是字符串相加
print(float(age)+float(height)+float(weight))  # 这个就没有问题了

print("How old are you?", end=' ')                     # How old are you? 45
age = input()
print("How tall are you?", end='')                     # How tall are you? 173
height = input()
print("How much do you weight?", end='')               # How much do you weight? 80
weight = input()

print(f"So, you're {age} old, {height} tall and {weight} heavy.")  # so,you're 45 old, 173 tall and 80 weight.

"""
换一种写法:
age = input("How old are you?",)                        # 强迫症犯了,为什么有下划线,为什么抄一遍就没有
age = input("How old are you?",)
height = input("How tall are you?",)
weight = input("How much do you weight?",)
print(f"So, you're {age} old, {height} tall and {weight} heavy.")

"""
"""
input()
1、有问有答,终端区输入
2、函数好用,赋值第一,必须赋值
3、input的提示信息也是输出
4、输入类型必为str,数字需要转换类型int or float
"""
print(age+height+weight)    # 所以,输入42、160、80运行结果为4216080,是字符串相加
print(float(age)+float(height)+float(weight))  # 这个就没有问题了

  • 6
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值