수안보중학교 로고이미지

RSS 페이스북 공유하기 트위터 공유하기 카카오톡 공유하기 카카오스토리 공유하기 네이버밴드 공유하기 프린트하기
19. python_019.py(색깔별 그리기)
작성자 수안보중 등록일 19.11.06 조회수 40
첨부파일



#python_019.py(색깔별 그리기)

import turtle

t = turtle.Pen()

t.shape("turtle")

reptilia = ['turtle', 'crocodile', 'iguana', 'chameleon']

amphibian = ['frog', 'toad', 'axolotl']

if 'turtle' in reptilia:

t.color('red')

t.forward(100)

if 'turtle' in reptilia:

t.color('blue')

t.right(100)

if 'turtle' in reptilia:

t.color('green')

t.forward(150)

if 'turtle' not in amphibian:

t.color('blue')

t.right(70)

<결과>

 

009
 

 

 

 

 

 

이전글 20. python_020.py(색깔별 선택후 선그리기)
다음글 18. python_018.py(조건 만족시 그리기)