在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'>