在IDLE交互环境下使用如下代码可查看python的关键字:
import keyword
keyword.kwlist
结果会以列表形式显示出来.
以下是版本python 3.6.3的关键字:
['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']
Python的平方根函数内置在math模块中,所以要调用Sqrt()函数必须先import math模块,返回结果为一个浮点型数字
import math
math.sqrt()
>>> math.sqrt(25)
5.0
>>> math.sqrt(80)
8.94427190999916
>>> type(math.sqrt(81))
<class 'float'>