Notice
Recent Posts
Recent Comments
250x250
Creative Code
Chapter10(모듈,패키지) 본문
728x90
# random 모듈을 import하여 난수 생성과 관련된 함수들을 사용합니다.
import random
# random.randint() 함수를 사용하여 1에서 1000 사이의 무작위 정수를 출력합니다.
print(random.randint(1, 1000))
# random.randint() 함수를 사용하여 0에서 100 사이의 무작위 정수를 출력합니다.
print(random.randint(0, 100))
# random.random() 함수를 사용하여 0과 1 사이의 무작위 부동 소수점 숫자를 출력합니다.
print(random.random())
# time 모듈을 import하여 시간과 관련된 함수들을 사용합니다.
import time
# time.localtime() 함수를 사용하여 현재 시간을 지역 시간대로 출력합니다.
print(time.localtime())
# urllib.request 모듈을 import하여 웹 페이지에 HTTP 요청을 보냅니다.
import urllib.request
# 'https://harucode.tistory.com' 주소로 HTTP GET 요청을 보내고, 응답을 저장합니다.
response = urllib.request.urlopen('https://harucode.tistory.com')
# 응답을 읽고 출력합니다.
print(response.read())
# matplotlib 모듈을 import하여 데이터 시각화를 위한 함수들을 사용합니다.
import matplotlib.pyplot as plt
# plt.plot() 함수를 사용하여 주어진 데이터 [1, 2, 3, 4]를 선 그래프로 그립니다.
plt.plot([1, 2, 3, 4])
# plt.ylabel() 함수를 사용하여 y 축의 레이블을 설정합니다.
plt.ylabel('some numbers')
# plt.show() 함수를 사용하여 그래프를 화면에 출력합니다.
plt.show()
728x90
'코딩 study > python' 카테고리의 다른 글
Chapter12(CSV,로그) (0) | 2023.10.23 |
---|---|
Chapter11(예외처리,파일입출력) (0) | 2023.10.22 |
Chapter9(클래스,상속,가시성) (0) | 2023.10.21 |
Chapter8(파이썬 스타일 코드) (0) | 2023.10.19 |
Chapter7(파이썬 스타일 코드) (0) | 2023.10.19 |