홈페이지 접속
pyCharm 홈페이지
Community 다운로드
Next 체크
경로 설정후 Next 체크
모두 체크
Install 체크
C드라이브에 Python폴더 생성
# ex2.py
# input으로 받은 값은 모두 문자.
a = int(input("첫번째 숫자를 입력하세요"))
b = int(input("두번째 숫자를 입력하세요"))
result = a + b
print(result)
result = a - b
print(result)
result = a * b
print(result)
result = a / b
print(result)
# ex3.py
import turtle
turtle.shape('turtle')
turtle.color('red')
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
#ex4.py
import turtle
t = turtle.Turtle()
t.shape('turtle')
t.color('red')
t.forward(200)
t.right(90)
t.forward(200)
t.right(90)
t.forward(200)
t.right(90)
t.forward(200)
t.right(90)
turtle.done()
#ex5.py
import turtle
myT = None
myT = turtle.Turtle()
# 화살표
myT.shape('classic')
# python for문 사용법 (100번 실행)
for i in range(0,100):
myT.forward(200)
myT.right(90)
turtle.done()
# ex6.py
import turtle
import random
# 함수선언 부분 #
def screenLeftClick(x,y):
# global 선언 시 전역변수
global r, g, b
turtle.pencolor((r,g,b))
turtle.goto(x,y)
def screenRightClick(x,y):
turtle.penup()
turtle.goto(x,y)
def screenMidClick(x,y):
global r, g, b
tSize = random.randrange(1,10)
turtle.shape(tSize)
r = random.random()
g = random.random()
b = random.random()
pSize = 10
r,g,b = 0.0, 0.0, 0.0;
turtle.title("거북이 그림 그리기")
turtle.shape('turtle')
turtle.pensize(pSize)
turtle.onscreenclick(screenLeftClick, 1)
turtle.onscreenclick(screenRightClick, 2)
turtle.onscreenclick(screenRightClick, 3)
turtle.done()