Python common function library

math library

Simple addition, subtraction, multiplication and division can be used directly, but when you want to use the operation of taking the absolute value of the square root, you need to introduce python's mathematical function library

import math
import math
a = 5
print(math.sqrt(a))

Please add a picture description

random number

import random
i = 1
while(i < 5):
    i = i+1
    print("the random function")
    print(random.random())#random函数随机产生0-1的任意实数
    print("the uniform function")
    print(random.uniform(1, 5))#uniform函数随机产生自定义范围内的函数

Guess you like

Origin blog.csdn.net/qq_52109814/article/details/121660722