看板 Python 關於我們 聯絡資訊
Instructions On line 2, fill in the if statement to check if answer is greater than 5. On line 4, fill in the elif so that the function outputs -1 if answer is less than 5. def greater_less_equal_5(answer): if ________: return 1 elif ________: return -1 else: return 0 print greater_less_equal_5(4) print greater_less_equal_5(5) print greater_less_equal_5(6) 這是codecademy的題目 想問if return 1是什麼意思? return -1又是什麼意思? return 0又是什麼意思? Tks! -------------------------------- 後來我解出來原來是因為他前面還有段說明 一直把answer當作要寫一個判斷式大於5或小於5 所以方向完全錯誤 Instructions On line 2, fill in the if statement to check if answer is greater than 5. On line 4, fill in the elif so that the function outputs -1 if answer is less than 5. def greater_less_equal_5(answer): if answer>5: return 1 elif answer<5: return -1 else: return 0 print greater_less_equal_5(4) print greater_less_equal_5(5) print greater_less_equal_5(6) 好吧 知道答案以後覺得真的蠻蠢的XD 但也沒有每題都答不出來拉..... 卡關才上PTT求救..... 請各位高手高抬貴手 ~ 感恩 -- Every man for himself and God against them all. -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 61.221.60.128 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1433721315.A.6AF.html
alibuda174: 就是回傳1 -1 0啊,分別代表參數與5的三種大小關係 06/08 08:47
cpper: 你的問題不在-1,1,0是什麼意思?而在你看不懂英文 06/08 09:50
cpper: 你該進修的除了Python外,還有英文 06/08 09:50
cpper: 題目英文已經說明得一清二楚,還要問意思? 06/08 09:50
...... 那請問答案要填什麼?
infit: 沒難度 06/08 11:19
math99: 靠杯 原 po 讓我笑好久 給你推 06/08 12:45
能帶給你歡樂很高興 那可以提供一下答案嗎?
fineaisa: 要不要考慮先看中文書啊… 06/08 13:43
Hikkiaholic: XD 不過coeacademy有題目喔?? 一直不知道 06/08 14:53
Hikkiaholic: 只知道有教學 有人能給題目連結嗎? 06/08 14:54
Neisseria: http://www.codecademy.com/en/tracks/python 06/08 17:24
※ 編輯: femlro (106.1.185.58), 06/08/2015 17:57:18 ※ 編輯: femlro (106.1.185.58), 06/08/2015 17:57:38
AndCycle: 老實說這樣就看不懂後面你每題都會上來問, 不會有人理你 06/08 18:26
= =我答出來 原來我的問題是我沒在比大小前面+answer這個變數 加上去就好了.... ※ 編輯: femlro (106.1.185.58), 06/08/2015 18:28:23 ※ 編輯: femlro (106.1.185.58), 06/08/2015 18:51:25
infit: 明明coursera forum上都有答案 06/08 19:02
python相關課程? ※ 編輯: femlro (106.1.185.58), 06/08/2015 19:07:04
infit: 說錯是codecademy 06/08 20:23