笨方法python3_“笨方法”学Python3,习题 12 。

ced13d3a92efa393349f765d6ddd016b.png

笨方法”学Python3,习题 12:提示别人

1、如何在input函数中提示别人?

一、基础代码

所写的代码:
age = input("How old are you? ")
height = input("How tall are you? ")
weight = input("How much do you weigh? ")
 
print(f"So, you are {age} old, {height} tall and {weight} heavy.")
---------------------------------------------------------------------------------------------------
应该看到的结果:
PS D:代码> & D:/软件/python/python.exe d:/代码/ex12.py
How old are you? 19
How tall are you? 197
How much do you weigh? 167
So, you are 19 old, 197 tall and 167 heavy.

2860ee2aff3e9c0887b3fc5ecf2efe05.png

二、巩固练习

1、在终端用pydoc查找input函数(终端就是平时输出结果的地方)

pydoc是python自带的一个文档生成工具,使用pydoc可以很方便的查看类和方法结构

PS D:代码> python -m pydoc input
Help on built-in function input in module builtins:                                                                                                        

input(prompt=None, /)
    Read a string from standard input.  The trailing newline is stripped.

    The prompt string, if given, is printed to standard output without a
    trailing newline before reading input.

    If the user hits EOF (*nix: Ctrl-D, Windows: Ctrl-Z+Return), raise EOFError.
    On *nix systems, readline is used if available.

395feb5a4413ee7b3e0e8d0ec9f4e119.png

总结:

1、input函数可以提示别人,通过在括号里写入字符串达到效果

2、pydoc可以查找函数的用法

^ v ^,知乎此系列文章内容均会在微信公众号中同步更新,公众号:小民有个小旮旯

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值