[問題] 請問怎麼解此題?

看板Python作者 (股權成就你的財富)時間10年前 (2015/06/08 07:55), 10年前編輯推噓5(508)
留言13則, 8人參與, 最新討論串1/1
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

06/08 08:47, , 1F
就是回傳1 -1 0啊,分別代表參數與5的三種大小關係
06/08 08:47, 1F

06/08 09:50, , 2F
你的問題不在-1,1,0是什麼意思?而在你看不懂英文
06/08 09:50, 2F

06/08 09:50, , 3F
你該進修的除了Python外,還有英文
06/08 09:50, 3F

06/08 09:50, , 4F
題目英文已經說明得一清二楚,還要問意思?
06/08 09:50, 4F
...... 那請問答案要填什麼?

06/08 11:19, , 5F
沒難度
06/08 11:19, 5F

06/08 12:45, , 6F
靠杯 原 po 讓我笑好久 給你推
06/08 12:45, 6F
能帶給你歡樂很高興 那可以提供一下答案嗎?

06/08 13:43, , 7F
要不要考慮先看中文書啊…
06/08 13:43, 7F

06/08 14:53, , 8F
XD 不過coeacademy有題目喔?? 一直不知道
06/08 14:53, 8F

06/08 14:54, , 9F
只知道有教學 有人能給題目連結嗎?
06/08 14:54, 9F

06/08 17:24, , 10F
※ 編輯: femlro (106.1.185.58), 06/08/2015 17:57:18 ※ 編輯: femlro (106.1.185.58), 06/08/2015 17:57:38

06/08 18:26, , 11F
老實說這樣就看不懂後面你每題都會上來問, 不會有人理你
06/08 18:26, 11F
= =我答出來 原來我的問題是我沒在比大小前面+answer這個變數 加上去就好了.... ※ 編輯: femlro (106.1.185.58), 06/08/2015 18:28:23 ※ 編輯: femlro (106.1.185.58), 06/08/2015 18:51:25

06/08 19:02, , 12F
明明coursera forum上都有答案
06/08 19:02, 12F
python相關課程? ※ 編輯: femlro (106.1.185.58), 06/08/2015 19:07:04

06/08 20:23, , 13F
說錯是codecademy
06/08 20:23, 13F
文章代碼(AID): #1LTDdZQl (Python)
文章代碼(AID): #1LTDdZQl (Python)