I have 99 problems, but switch aint one


#1

Hello, I'm also having the same problem

def greater_less_equal_5(answer):
if 6>5: #fill in if statement to check if answer > 5
return 1 #what does return 1, -1 and 0 refer to?
elif 4<5 : #fill in elif so that function outputs -1 if answer < 5
return -1
else:
return 0

print greater_less_equal_5(4) #what are these?
print greater_less_equal_5(5)
print greater_less_equal_5(6)

Oops, try again. It looks like your function output 1 instead of -1 when answer is 3.

I think this is referring to elif statement... when "answer is 3"(I don't get this?)

Thanks


Lesson 14 - I have 99 problems, but a switch is not a
#2

this are function calls:

print greater_less_equal_5(4) #what are these?
print greater_less_equal_5(5)
print greater_less_equal_5(6)

the value (4, 5 or 6) supplied as argument at function call get copied into the function parameter (answer)

so the value of answer depends on the argument you supply at function call. So using answer in your if/elif condition we are able to build a function which can tell use if the number supplied as argument on function call is greater, equal or smaller then 5


#3

thanks... I'll try to digest what you just said. sorry about the bold letters.


#4

Hey, man, did you get this lesson sorted out?

Edit:I was able to solve it (not alone).


#5

can you also help me as well on this one


#6

How should people who are struggling with the exercise themselves help you? Its like asking someone who is drowning to teach you how to swim.

please go here, make a new topic, fill in all the information asked for by the template, so someone with the skills and knowledge can teach you how to swim


#7

well sorry sir I'm only 14 trying to learn on of the hardest programming language and I'm getting frustrated and I'm just asking for help so there was no need for a reply back


#8

well, without details like code, error message and your thoughts to what you do understand, its really difficult to nearly impossible to help you


#9

Without knowing what a function is and how it operates, it is going to be very difficult for a beginner to get this right.

In my opinion, this test doesn't belong in the conditionals section...

Keep at it azere, you'll understand it by the time you get to the function section.


#10

you get most of the code, and the instructions tell you the conditions. But yes, its still tricky.


#11

BTW, thanks for your help.


#12

@azere and @byteninja80135
Guys, I sinned a lot trying to understand the lesson. I received the answer by asking in another forum because you really can not understand the instruction of the lesson.

I will try to explain in my own way what you have to do in this lesson.
Both statements ask you to use the answer statement to construct the function, that is, the answer statement will be one of the values / algorithms of this function.

If you do not understand, answer here and I'll send you the answer through the message.

PS: If any of you can speak Brazilian Portuguese, it will be better for me to communicate with you. My English writing is reasonable.


#13

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.