【发布时间】:2020-09-27 19:56:44
【问题描述】:
所以我正在开一家太阳镜店。 这是我的代码:
# Sun_Glasses_Shop
import turtle
import random
from random import randint
def build_glasses() :
crim = turtle.Turtle()
colors = ['red', 'blue', 'green', 'yellow', 'plum', 'sienna']
crim.color(random.choice(colors), random.choice(colors))
randpos = randint(-100, 100)
crim.width(2)
crim.penup()
crim.setposition(randpos, randpos)
crim.pendown()
# Making First Box
crim.begin_fill()
for x in range(4):
crim.forward(50)
crim.right(90)
crim.end_fill()
crim.forward(50)
crim.right(90)
crim.forward(5)
crim.left(90)
crim.forward(50)
crim.left(90)
crim.forward(5)
crim.right(90)
crim.begin_fill()
# Making Second Box
for x in range(4):
crim.forward(50)
crim.right(90)
crim.end_fill()
print("Welcome to the glasses shop, would you like some?")
A1 = str(input())
if A1 == "yes" or A1 == "Yes" :
A1 = str(input()) print("Okay, coming right up!")
build_glasses()
else :
print("I dont understand try asking me later, bye!")
但是当我运行代码时,它会在模块中打印出来:
Welcome to the glasses shop, would you like some?
yes
Okay, coming right up!
海龟图形不弹出。
【问题讨论】:
标签: python if-statement turtle-graphics