Reveiw Functions


#1

I need help with review functions 17! Please help here is my code. Please reply soon!! Comments welcome.

def shut_down(s):
m = s == "yes"
if shut_down
return "shutting down"
elif s = "no"
return "Shutdown aborted"
if shut_down
return "Sorry"


#2

#3

Tried that and it came out as a fail.


#4

Take a snapshot of the entire lesson so I see what the lesson wants.


#5

This is the lesson and instructions.

        Review: Functions


        Okay! Let's review functions.

def speak(message):
return message

if happy():
speak("I'm happy!")
elif sad():
speak("I'm sad.")
else:
speak("I don't know what I'm feeling.")

Again, the example code above is just there for your reference!

      
    
    
      
        Instructions
      
      
        First, def a function, shut_down, that takes one argument s. Don't forget the parentheses or the colon!Then, if the shut_down function receives an s equal to "yes", it should return "Shutting down"Alternatively, elif s is equal to "no", then the function should return "Shutdown aborted".Finally, if shut_down gets anything other than those inputs, the function should return "Sorry"

#6

Those if/else go inside your shut_down method:

  • If the message param is Yes, return "Shutting down".
  • If the message param is No, return "Shutting aborted".
  • Any other case, return "Sorry".

And you print the result of that method call.


Ok, so where did I got wrong with shut_down?
#7

I'm guessing you have figured this out by now, but I'll throw it out anyways.

Your code is nearly there, just a few things to change out.

Compare to the following and adjust, you will see the differences. Remember the indents need to be there.

def shut_down(s):
if s == "yes":
return ("Shutting down")
elif s == "no":
return ("Shutdown aborted")
else:
return ("Sorry")


#8

its not working.. can somebody help me with the solution ?


#9

have you got solution so reply it


#11

The code is alright. the only error is in the indentation. all you have to do is to give an indentation block under the def function!

P.S: Python is indentation concerned language, remember! :smiley:


#13