詹惠儿

2019-01-07   阅读量: 557

数据分析师

python的built-in模块

扫码加入数据分析学习群

# importing built-in module math

import math

# using square root(sqrt) function contained

# in math module

print math.sqrt(25)

# using pi function contained in math module

print math.pi

# 2 radians = 114.59 degreees

print math.degrees(2)

# 60 degrees = 1.04 radians

print math.radians(60)

# Sine of 2 radians

print math.sin(2)

# Cosine of 0.5 radians

print math.cos(0.5)

# Tangent of 0.23 radians

print math.tan(0.23)

# 1 * 2 * 3 * 4 = 24

print math.factorial(4)

# importing built in module random

import random

# printing random integer between 0 and 5

print random.randint(0, 5)

# print random floating point number between 0 and 1

print random.random()

# random number between 0 and 100

print random.random() * 100

List = [1, 4, True, 800, "python", 27, "hello"]

# using choice function in random module for choosing

# a random element from a set such as a list

print random.choice(List)

# importing built in module datetime

import datetime

from datetime import date

import time

# Returns the number of seconds since the

# Unix Epoch, January 1st 1970

print time.time()

# Converts a number of seconds to a date object

print date.fromtimestamp(454554)

添加CDA认证专家【维克多阿涛】,微信号:【cdashijiazhuang】,提供数据分析指导及CDA考试秘籍。已助千人通过CDA数字化人才认证。欢迎交流,共同成长!
0.0000 0 1 关注作者 收藏

评论(0)


暂无数据

推荐课程

推荐帖子