選擇會記在這個瀏覽器裡
if / elif / else
奶茶店的點單屏要顯示甜度。寫 sweetness(spoons):0 勺返回 "none",1 到 2 勺返回 "half",3 勺及以上返回 "full"。
sweetness(spoons)
"none"
"half"
"full"
sweetness(0)
'none'
sweetness(2)
'half'
sweetness(5)
'full'
def sweetness(spoons): if spoons == 0: return "none" # 在這裡寫:1 到 2 勺是 "half",再多是 "full" pass
寫好了先點「執行」試試示例,沒問題再點「提交」。
這一頁要開啟 JavaScript 才能寫程式碼。