수도 맞추기 그림 및 수도 정보

world map

import turtle as t
from countryinfo import country_data
import random

# 그래픽창 설정하기
t.setup(1325, 735)
t.title("수도 맞히기 게임 (종료를 입력하면 프로그램이 종료됩니다.)")
t.bgpic("world-map.gif")

# 터틀 속성 설정
t.penup()
t.speed(0)
t.shape("circle")
t.shapesize(0.5)
t.color("green")
t.goto(700, 350)

while True:
    cur_quiz = random.choice(country_data)
    user_input = t.textinput("국가별 수도 맞히기", f"{cur_quiz['국가']}의 수도는?")

    if user_input == "종료":
        break
    elif user_input in cur_quiz["수도"]:
        t.color("green")
    else:
        t.color("red")

    t.goto(cur_quiz["좌표"])
    t.clear()
    t.write(f"{cur_quiz['국가']}\n{cur_quiz['수도'][0]}", False, "center", \
            ("나눔바른펜", 20, "bold"))

# t.done()

Loading

댓글 남기기