#coding=utf-8
from sys import exit
name = raw_input("請爲自己取名>>>>>")
def start():
city_list = ['廣州','深圳', '河源']
for city in city_list:
print "這是你的選擇之一:%s." %city
#如果這裏接下來還有其他的print,會導致for函數只輸出一個值。
print "你想留在那個城市>>>>>>>>"
next = raw_input(">")
if "廣州" in next:
guangzhou()
elif "深圳" in next:
shenzhen()
elif "河源" in next:
heyuan()
else:
print "你必須要做出一個選擇,少年%s." % name
def guangzhou():
print "你好,%s!,廣州是一個充滿機會的城市,你願意留下來嗎?Y/N" % name
next = raw_input(">")
if "Y" in next:
print "在這裏,您可以成長成爲早教師,GOOD JOB!"
elif "N" in next:
print "回老家去吧,鄉村少年。"
heyuan() #跳至heyuan函數。
else:
dead("成爲流浪者吧,少年!")
def shenzhen():
print "你好,深圳是充滿機會的城市. %s,你覺得得付出百分幾的代價來成爲老闆?" % name
x = False
while True:
next = int(raw_input(">"))
if next <= 50:
print("成功不屬於你!%s") % name
elif next >= 80 and not x:
print "你有機會成功"
elif 50 <= next <= "80" and not x:
print "少年,機會有點渺茫啊"
else:
print "少年,把你真實想法寫下來吧。"
def dead(why):
print why, "good job"
exit(0)
def heyuan():
print "河源,青山綠水,歡迎您"
print "空氣清新,就是工作機會沒有這麼多而已"
print "您要逃離?還是留守?"
while True:
next = raw_input(">")
if "逃離" in next:
start()
elif "留守" in next:
print "您願意用百分之幾的努力來完成養豬任務?"
x = False
while True:
next = int(raw_input(">"))
if next <= 50:
print("成功不屬於你!%s") % name
elif next >= 80 and not x:
print "你有機會成功"
elif 50 <= next <= "80" and not x:
print "少年,機會有點渺茫啊"
else:
print "少年,把你真實想法寫下來吧。"
else:
print "做出一個選擇吧,少年。"
start = start()
習題35,36分支與函數,設計和調試,笨方法學python,中文版遊戲
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.