feedback revised 4

 avatar
user_0100208
plain_text
2 years ago
4.4 kB
3
Indexable
Never
total=[]
star=0
#Q1
while True:
   print("以下問卷兩題,若您願意填寫,請輸入Y,不願意填寫請輸入N")
   print("Y/N")
   x1=input()
   try:
        if x1 !="Y" and x1 != "N" and x1 != "y" and x1 != "n" and x1 !="":
            raise  KeyboardInterrupt
   except KeyboardInterrupt: 
        print ("錯誤! 請輸入Y或N")
   else:
    total.append(x1)
    if x1=="Y" or x1=="y": 
        print ("謝謝,請接續作答!")
        break
    else : 
        print("了解,謝謝!") 
        exit()

#Q2
while True:
   print("Q1: 整體而言,您會給這間酒吧幾顆星星")
   print("a.⭐ b.⭐⭐ c.⭐⭐⭐ d.⭐⭐⭐⭐ e.⭐⭐⭐⭐⭐")
   x2=input()
   try:
        if x2 != "a" and x2 !="b" and x2 !="c" and x2 !="d" and x2 !="e" and x2 != "A" and x2 !="B" and x2 !="C" and x2 !="D" and x2 !="E":
            raise  KeyboardInterrupt
   except KeyboardInterrupt: 
        print ("錯誤! 請輸入a,b,c,d,e,f")
   else: 
    total.append(x2)
    break

if x2=="a" or x2=="A": star="⭐"
elif x2=="b" or x2=="B": star="⭐⭐"
elif x2=="c" or x2=="C": star="⭐⭐⭐"
elif x2=="d" or x2=="D": star="⭐⭐⭐⭐" 
else: star="⭐⭐⭐⭐⭐"

#Q3
while True:
    if x2=="a" or x2=="b" or x2=="c": 
        dic={"a":"氣氛差", "b" :"食物差", "c" :"食物很貴", "d": "酒很難喝", "e": "酒太貴", "f":"環境骯髒", "g":"環境吵鬧", "h":"服務態度差", "i":"送餐速度太慢"}
        print ("請告訴我們為什麼您給予酒吧",star,"的評價?(複選,不需要以空格隔開。請注意大小寫!)")
        print("a.氣氛差 b.食物差 c.食物很貴 d.酒很難喝 e.酒太貴 f.環境骯髒 g.環境吵鬧 h.服務態度差 i.送餐速度太慢")
        y2=input()
        try:
            i=0
            for x in y2:
                if x not in ("a","b","c","d","e","f","g","h","i"):
                    i+=1
                else: i=i
            if i !=0:
                    raise  KeyboardInterrupt
        except KeyboardInterrupt: 
            print ("錯誤! 輸入選項只能涵蓋a,b,c,d,e,f,g,h,i。請注意大小寫")
        else:
            total.append(y2)
            print("感謝您的作答")
            break

    elif x2=="c":
        dic={"a":"氣氛普通", "b" :"食物普通", "c" :"食物cp值普通", "d": "酒很普通", "e": "酒cp值普通", "f":"環境普通", "g":"環境普通", "h":"服務態度普通", "i":"送餐速度普通"}
        print ("請告訴我們為什麼您給予酒吧",star,"的評價?(複選,不需要以空格隔開。請注意大小寫!)")
        print("a.氣氛普通 b.食物普通 c.食物cp值普通 d.酒很普通 e.酒cp值普通 f.環境普通 g.環境普通 h.服務態度普通 i.送餐速度普通")
        y2=input()
        try:
            i=0
            for x in y2:
                if x not in ("a","b","c","d","e","f","g","h","i"):
                    i+=1
                else: i=i
            if i !=0:
                    raise  KeyboardInterrupt
        except KeyboardInterrupt: 
            print ("錯誤! 輸入選項只能涵蓋a,b,c,d,e,f,g,h,i。請注意大小寫")
        else:
            total.append(y2)
            print("感謝您的作答")
            break
    else: 
        dic={"a":"氣氛佳", "b" :"食物好吃", "c" :"食物cp值高", "d": "酒很好喝", "e": "酒cp值很高", "f":"環境乾淨", "g":"環境安靜", "h":"服務態度佳", "i":"送餐速度很快"}
        print ("請告訴我們為什麼您給予酒吧",star,"的評價?(複選,不需要以空格隔開。請注意大小寫!)")
        print("a.氣氛佳 b.食物好吃 c.食物cp值高 d.酒很好喝 e.酒cp值很高 f.環境乾淨 g.環境安靜 h.服務態度佳 i.送餐速度很快")
        y2=input()
        try:
            i=0
            for x in y2:
                if x not in ("a","b","c","d","e","f","g","h","i"):
                    i+=1
                else: i=i
            if i !=0:
                    raise  KeyboardInterrupt
        except KeyboardInterrupt: 
            print ("錯誤! 輸入選項只能涵蓋a,b,c,d,e,f,g,h,i。請注意大小寫")
        else:
            total.append(y2)
            print("感謝您的作答")
            break

#print results
y3=[]
y4=[]
for x in y2:
    if x not in y3:
        y3.append(x)
        y4.append(dic.get(x))
print("1.是否答題:",x1,"2.給幾星:",star,"3.原因:",y4)