智航學編程006(字符串與時鐘、倒計時、紅綠燈)

import time
s="春曉"
t1="春眠不覺曉"
print(s)
time.sleep(0.5)
print(t1)
time.sleep(1)
print("處處聞啼鳥")
time.sleep(1)
print("夜來風雨聲")
time.sleep(1)
print("花落知多少")


for i in range(10):
    print("當前時間:",time.strftime("%Y/%m/%d %H:%M:%S"))
    time.sleep(1)



import time

s="火箭發射-倒計時開始:"

print(s)
count = 10
for i in range(10):
    print(count)
    time.sleep(0.5)
    count = count - 1
print("點火")
time.sleep(0.2)
print('進入平流層')
time.sleep(0.2)
print("""進入對流層
         發射點
         發射任務
         到達月球
""")

#字符串使用三個雙引號,可以自定義格式
menu = """
******菜單******
    麻辣小龍蝦
    麻辣鴨脖
****************
"""

print(menu)


#turtle實現紅綠燈
import turtle

turtle.screensize(500,500,"wheat")
t = turtle.Turtle()
t.speed(0)
t.pensize(1)
for i in range(2):
    t.fd(100)
    t.left(90)
    t.fd(350)
    t.left(90)
time.sleep(1)
t.pu()
t.goto(50,50)
t.pd()
t.color("red")
t.begin_fill()
t.circle(40)
t.end_fill()

time.sleep(1)
t.pu()
t.goto(50,150)
t.pd()
t.color("yellow")
t.begin_fill()
t.circle(40)
t.end_fill()

time.sleep(1)
t.pu()
t.goto(50,250)
t.pd()
t.color("green")
t.begin_fill()
t.circle(40)
t.end_fill()

t.ht()

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章