Review:Functions


#1

This is the code i have written,
def shut_down(s):
return s

if shut_down(s):
s == 'yes'
shut_down("shutting donw")

elif shut_down(s):
s == 'no'
shut_down("shutting abprted")

else:
shut_down ("sorry")

print shut_down(yes)

I get the error saying that 's' is not defined,
Can anyone please help me with this code?


#2

def shut_down(s):
if s():
return"shutting_down"
elif s():
return"shutdown aborted"
else:
return"sorry"

is a better way to do this but its not right.hope it helps


#3

never mind that this one works

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


#4

It is due to the IndentationError. The correct one is as below. Hope this helps

def shut_down(s):
return s

if shut_down(s):
    s == "yes"
    shut_down("shutting donw")

elif shut_down(s):
    s == "no"
    shut_down("shutting abprted")

   else:
     shut_down ("sorry")

print shut_down("yes")


#5

Here is what you need to do :smile: