17/19


#1

hey guys, I’m stumped on this problem. I don’t know where to go from here. Can anyone point me in the right direction? heres my code

def shut_down(s):
  if yes():
    return ("Shutting Down")
  elif no():
    return ("Shutdown aborted")

  else:
    return ("Sorry")

#2

you literally have to type, what the exercise says. Function parameters and arguments aren’t explained at this point yet.

So, a function can have a parameter, in your case s:

# function deceleration with parameter `s`
def shut_down(s):

then s gets its value from parameter at function call:

def shut_down(s):
    print s

# function call with argument
# the argument gets passed to function parameter
shut_down("see?")

so you have to compare s with certain strings, to see if user wants to shut down the computer


#3

def shut_down(s):

‘s’ is the variable established for multiple purposes so you can define ‘s’ as either ‘yes’ or ‘no’

the coding should be as follows

def shut_down(s):
if s == ‘yes’: #don’t forget your colon
return "Shutting Down"
elif s == ‘no’: #don’t forget your colon
return "Shutdown aborted"
else: #don’t forget your colon
return “Sorry”

So, when you look back at the code you can see that you have effectively established ‘s’ as an on-off switch with the variables ‘yes’ and ‘no’ in the place of on and/or off.

I hope this helps. I swore at this thing multiple times and had it give me the code multiple times before I was able to piece this answer together. Hope it helps. Keep at it.


#4

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