Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 17 Online
OpenStudy (siberman):

Hi, so i've got a bit of a general question about abstractions, if i put "return best_value" as the conclusion for instance, go i now have the global variable 'best_value' available? Otherwise, do i need to say, def get_best_value() newVariable = get_best_value() In order to link the output to a variable? I'm working on pset6 at the moment, and with all those definitions flying around i've found myself a little confused. Thanks.

OpenStudy (anonymous):

http://pastebin.com/hb4bQGyL

OpenStudy (siberman):

Hey, thanks for that, so this leads to the further question, what if a function has multiple outputs? Is it necessary to us the function to populate a list?

OpenStudy (anonymous):

there is only one return statement. if you want to return more than one thing you can put them in a list or a dictionary or a tuple. you can return any type of object. http://dpaste.com/711361/

OpenStudy (siberman):

That's what i thought, i guess returning a dictionary with meaningful keys would be a good way to go. Thanks for the clarification,

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!