Python 다운로드 (2023.05.10)

상목·2023년 5월 10일
0

Python

목록 보기
1/1

<Python 다운로드>

Python 다운로드 홈페이지

  1. Python 홈페이지로 들어간다.

  1. 두개 모두 체크 한후 Install Now 클릭

  1. 다운로드 후 cmd창에서 python -V 명령어 입력하면 다운로드 버전 확인 가능.

<pyCharm 다운로드>

  1. 홈페이지 접속
    pyCharm 홈페이지

  2. Community 다운로드

  3. Next 체크

  4. 경로 설정후 Next 체크

  5. 모두 체크

  6. Install 체크

  7. C드라이브에 Python폴더 생성

<pyCharm 프로젝트 생성>

<pyCharm 프로젝트 세팅>

  1. 폰트 설정


<Python 팁>

input() 함수로 받은 값은 모두 문자 -> int(input()) 으로 적으면 쉽게 정수형으로 변환가능


# 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)

<turtle 함수는 도형을 그리기 위한 python 함수>

원 그리기

# 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()

사각형 그리기 + for문 + 화살표 모양 표시

#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()

함수 사용과 random , turtle 사용

# 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()
profile
풀스택 개발 이야기

0개의 댓글