Thông tin dự án
Học phần 2 - LẬP TRÌNH PYTHON & KHOA HỌC MÁY TÍNH
codekitten
Giới thiệu sản phẩm
"""
import turtle as t

screen = t.Screen()
screen.title("Turtle graphics")

player = t.Turtle()
player.pensize(5)
player.pencolor("#F9DB00")
'''
player.forward(100)
player.right(90)
player.backward(100)
player.left(90)
'''
def square():
    for i in range(4):
        player.forward(100)
        player.left(90)

square()
player.pencolor("#694200")
player.pu()
player.fd(150)
player.pd()
square()

player.fillcolor("blue")
t.begin_fill()
t.shape("triangle")
"""
import turtle

def square():
    t = turtle.Turtle()
    s = int(input("side of the square: "))
    col = input("color name or hex value of color(#RRGGBB): ")
    t.fillcolor(col)
    t.begin_fill()
    # drawing the square of side s
    for _ in range(4):
        t.forward(s)
        t.right(90)
    t.end_fill()

def triangle():
    t = turtle.Turtle()
    s = int(input("side of the triangle: "))
    col = input("color name or hex value of color(#RRGGBB): ")
    t.fillcolor(col)
    t.begin_fill()
    # drawing the square of side s
    for _ in range(3):
        t.forward(s)
        t.right(-120)
    t.end_fill()

def co_viet_nam():
    screen = turtle.Screen()
    #screen.setup(300, 200)
    t = turtle.Turtle()
    t.fillcolor("red")
    t.pu()
    t.goto(-150, 100)
    t.pd()
    t.begin_fill()
    t.forward(300)
    t.right(90)
    t.forward(200)
    t.right(90)
    t.forward(300)
    t.right(90)
    t.forward(200)
    #
    t.end_fill()
    t.pu()
    t.goto(-45,-60)
    t.right(18)
    t.pd()
    #s = int(input("side of the star: "))
    #col = input("color name or hex value of color(#RRGGBB): ")
    t.fillcolor("yellow")
    t.begin_fill()
    # drawing the star of side s
    for _ in range(5):
        t.forward(150)
        t.right(144)
    t.end_fill()
    #
    t.forward(57.5)
    t.fillcolor("yellow")
    t.begin_fill()
    for _ in range(5):
        t.forward(35)
        t.right(180 - 108)
    t.end_fill()

def house():
    t = turtle.Turtle()
    t.pu()
    t.goto(-100, -100)
    t.left(90)
    #wall
    t.fillcolor("grey")
    t.begin_fill()
    t.forward(300)
    t.right(90)
    t.forward(200)
    t.right(90)
    t.forward(300)
    t.right(90)
    t.forward(140)
    t.end_fill()
    #door
    t.fillcolor("#452A00")
    t.begin_fill()
    t.right(90)
    t.forward(100)
    t.right(90)
    t.forward(70)
    t.right(90)
    t.forward(100)
    t.right(90)
    t.forward(70)
    t.end_fill()
    #go to roof
    t.forward(60)
    t.right(90)
    t.forward(300)
    #roof
    x = 142
    t.fillcolor("red")
    t.begin_fill()
    t.right(45)
    t.forward(x)
    t.right(90)
    t.forward(x)
    t.right(135)
    t.forward(200)
    t.end_fill()
    #window
    t.goto(0,100)
    #t.forward(30)
    t.fillcolor("#00FFFF")
    t.begin_fill()
    t.speed(0)
    for _ in range(180):
        t.forward(1.5)
        t.right(2)
    t.end_fill()
    
#co_viet_nam()
house()

avatar
Turtle graphics
+0
0 bình luận
1 đã xem

Đăng nhập để tham gia bình luận

Các khoá học lập trình bạn muốn biết?
avatar
Tác giả
4366
Thông tin

Dự án 15 sản phẩm

Dự án cùng môn
Dự án cùng chủ đề