math-example.py¶
# -*- coding: utf-8 -*-
# @Date : 2018-11-01
# @Author : Peng Shiyu
# math 模块提供浮点数数学运算
import math
print(math.pi)
print(math.e)
"""
3.141592653589793
2.718281828459045
"""
# cmath 提供复数计算
import cmath
print(cmath.pi)
# 3.141592653589793
print(cmath.sqrt(-1))
# 1j
print(2 + 3j + 2 + 2j)
# (4+5j)