mylist = [1, 2, 3]

print(mylist) #함수

mylist.append(1) #메서드 점을 찍어서 사용할 수 있다.

import random
#모듈을 쓰려면 import로 불러와야한다.
#모듈 안에는 특정 기능을 하는 함수가 들어있다.

print(random.randrange(0, 10))
#범위를 지정하고 범위 안에 있는 숫자가 무작위로 출력된다.
#모듈을 쓰는 법: 모듈이름 뒤에 점(.)을 붙이고 함수를 적는다.

mylist = ['가', '나', '다']
a = random.randrange(0,2)
print(mylist[a])
#난수를 통해 랜덤한 문자를 출력하고 싶을 때

print(random.choice(['라','마','바']))
#시퀀스 원소 중 하나를 무작위로 출력

print(random.sample(range(1, 20),3))
#여러 개의 난수를 출력할 수 있는 함수
#1부터 20까지 중 3개의 숫자를 출력한다.

import math
print(math.pi) #파이 구하기
print(math.ceil(4.6)) #올림하여 정수로 반환하기

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: