作者femlro (股权成就你的财富)
看板Python
标题[问题] 请问怎麽解此题?
时间Mon Jun 8 07:55:11 2015
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://webptt.com/cn.aspx?n=bbs/Python/M.1433721315.A.6AF.html
1F:→ alibuda174: 就是回传1 -1 0啊,分别代表参数与5的三种大小关系 06/08 08:47
2F:推 cpper: 你的问题不在-1,1,0是什麽意思?而在你看不懂英文 06/08 09:50
3F:→ cpper: 你该进修的除了Python外,还有英文 06/08 09:50
4F:→ cpper: 题目英文已经说明得一清二楚,还要问意思? 06/08 09:50
......
那请问答案要填什麽?
5F:推 infit: 没难度 06/08 11:19
6F:推 math99: 靠杯 原 po 让我笑好久 给你推 06/08 12:45
能带给你欢乐很高兴
那可以提供一下答案吗?
7F:→ fineaisa: 要不要考虑先看中文书啊… 06/08 13:43
8F:推 Hikkiaholic: XD 不过coeacademy有题目喔?? 一直不知道 06/08 14:53
9F:→ Hikkiaholic: 只知道有教学 有人能给题目连结吗? 06/08 14:54
※ 编辑: femlro (106.1.185.58), 06/08/2015 17:57:18
※ 编辑: femlro (106.1.185.58), 06/08/2015 17:57:38
11F:→ 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
12F:→ infit: 明明coursera forum上都有答案 06/08 19:02
python相关课程?
※ 编辑: femlro (106.1.185.58), 06/08/2015 19:07:04
13F:推 infit: 说错是codecademy 06/08 20:23