I Got 99 Problems, But a Switch Ain't One


#1



https://www.codecademy.com/courses/python-beginner-BxUFN/3/4?curriculum_id=4f89dab3d788890003000096#


I am lost on what I need to do any help would be wonderful


HELP!PLZZZZ:confounded:


def greater_less_equal_5(answer):
    if 4 > 5:
        return 1
    elif 6 < 5:          
        return -1
    else:
        return 0
        
print greater_less_equal_5(4)
print greater_less_equal_5(5)
print greater_less_equal_5(6)


#2


#3

Hi you define a function with a argument answer so you should use it in your if and else if statement


#4

Wait sorry what?
What do you mean by that?


#5

Basically you have already defined your answer variable, so you are doing more than you need to when typing your numbers before the comparators in your function. CC comes up with a number and assigns it to answer for you, so you just need to use that instead of using your own numbers.


#6

You are passing the function a variable (answer) but it is never actually used in your function definition. Just read through your if statements and you will agree that 4 is not greater than 5 so it will never return 1. Similarly 6 is not less than 5. This is why you return all 0's.

You want to pass in the argument into the if statements.

eg.
if answer>5 :
return 1
if answer <5 :
return 1


#7

Thank you I will try it now and see what happens.


#8

I do not know what I am doing wrong now rip brains


#9

Like the instruction says..
if statement to check if answer is greater than 5.
Do you see how it should be now?
then it says..
elif so that the function outputs -1 if answer is less than 5.


#10

I am sorry bro still confused really sorry :disappointed:


#11

You still are not passing in a variable (answers) You are hardcoding your if statements.

you have
if 6>5 :

The aim of this exercise is to test if some variable is greater than or less than. The three function calls at the bottom are testing those numbers against the conditions. So by hardcoding statements, your function really doesn't do anything.

This is a screen shot of mine. noting how in my if blocks I am comparing the variable against a value. You have a value vs a value.


#12

ohhhhhhhhhhhhhhhhhh lol. Thank you very much good sir this makes it clear :kissing_heart: no homo


#13

and off topic do they do c and c++ coding on here or can I learn that elsewhere


#14

There are a ton of interactive tutorials for c out there. Just hit the google. http://www.sololearn.com/ has a c++ program


#15

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