笨办法学python 习题11:提问

熟悉输入

1、在 Python2.x 中 raw_input( ) 和 input( ),两个函数都存在,其中区别为:

  • raw_input( ) 将所有输入作为字符串看待,返回字符串类型。
  • input( ) 只能接收"数字"的输入,在对待纯数字输入时具有自己的特性,它返回所输入的数字的类型( int, float )。

2、在 Python3.x 中 raw_input( ) 和 input( ) 进行了整合,去除了 raw_input( ),仅保留了 input( ) 函数,其接收任意任性输入,将所有输入默认为字符串处理,并返回字符串类型。

来自 <https://www.runoob.com/w3cnote/python2-python3-raw_input-and-input.html>

练习

#python3 用input()输入   , end = ""控制不换行
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 ("So, you're %r old, %r tall and %r heavy."% ( age, height, weight))

打印结果

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值