Python

    파이썬 Turtle을 사용해서 다양한 도형 그려보기

    파이썬 Turtle을 사용해서 다양한 도형 그려보기

    요즘 과제시즌인지.. Turtle관련 도형 그리기 질문이 많이들어와서 소스를 짜봤습니다. 문과계열 학생들이.. 파이썬이 필수과정으로 들어가며 고통받는다는데 많은 도움이 되셨으면 합니다. 먼저 제 소스를 보면 아시겠지만 turtle.forward, turtle.right 요거 두개만 주로 쓰기 때문에 따로 코드 설명할꺼는 없는것 같습니다. 객체형태로 재사용 가능하게끔 만들었고, 과제하실때 소스코드 참고하셔서 만들수 있으면 좋을거 같습니다. import turtle import math turtle.shape('turtle') class Myturtle: def __init__(self, turtle, speed=2, angle=0): self.turtle = turtle self.speed = speed ..

    numpy 정리

    numpy 문법 초간단 정리! numpy 다양한 선언¶ In [1]: import numpy as np # 선언 a = np.array([1, 2, 3, 4]) print('리스트로 선언\n', a) a = np.zeros(4, dtype=int) # 0으로 채운 길이 4의 정수 배열 print('zeros\n', a) a = np.ones((3, 5), dtype=float) # 1로 채운 3x5 float 배열 print('ones\n', a) a = np.full((3, 5), 3.14) # 특성 element로 채움 print('full\n', a) a = np.arange(0, 20, 2) # 0-20, 2간격, 실수 간격도 가능 prin..

    주피터 노트북(jupyter notebook) pdf 변환

    주피터 노트북(jupyter notebook) pdf 변환

    nbconvert failed: Pandoc wasn't found. Please check that pandoc is installed: https://pandoc.org/installing.html jupyter notebook에서 download as pdf via LaTex를 고르면 에러난당 해결책은 간단하다.. 깔라는거 깔면됨(아니 pdf변환하는데 머 이리 까는게 많아?! =ㅅ=) 뭔가 많이 까는거 싫어하면 맨 아래 우회방법 적어둠.. Installation — nbconvert 6.0.8.dev0 documentation The Miniconda and Miniforge distributions both provide a minimal conda installation. Important To..

    파이썬 특정 시간이 지난 후 함수 종료하기

    스레드나 멀티 프로세스를 이용하여 특정 시간이 지난 후 함수를 종료하는 방법을 알아보도록 하겠습니다. # 시간이 지난 후 스레드 종료하기(원하는곳에서 종료가능) import threading import time from apscheduler.schedulers.background import BackgroundScheduler def start(): print("start") t = threading.Thread(target=run, args=("run함수",)) t.start() return t def run(arg): print("run") t = threading.currentThread() while getattr(t, 'do_run', True): # do_run 값이 정의되지 않는 경우 Tr..