๐ ํ์ด์ฌ Python
ํ์ด์ฌ - Import math , random
Meteora_
2021. 6. 28. 01:11
728x90
import math
print(math.sin(1))
print(math.cos(1))
print(math.tan(1))
print(math.floor(2.5)) # ๋ด๋ฆผ
print(math.ceil(2.5)) # ์ฌ๋ฆผ
# ์ฌ์ฌ์ค์
์์น. ๋ฐ์ฌ๋ฆผํ ์๋ฆฌ์ ์๊ฐ 5์ด๋ฉด ๋ฐ์ฌ๋ฆผํ ๊ฒฝ์ฐ ์์๋ฆฌ๊ฐ ์ง์๋ฉด ๋ด๋ฆผ, ํ์๋ฉด ์ฌ๋ฆผ
print(round(1.5))
print(round(2.5))
print(round(3.1415, 2))
print(round(31.415, -1))
import random
print(random.random()) # 0.0 <= r < 1.0
# uniform
print(random.uniform(10, 20)) # 10.0 ~ 19.99
print(random.randrange(10)) # 0 ~ 9
print(random.randrange(1, 5)) # 1 ~ 4
print(random.randint(1, 5)) # 1 ~ 5
print(random.choice([11, 33, 55, 7, 9]))
# shuffle
listA = [1, 2, 3, 4, 5]
random.shuffle(listA)
print(listA)
# sample
print(random.sample([1, 2, 3, 4, 5], k=5))