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

hi can someone pls explain the return command in detail for me with an example that will simplify it for me pls i need to understand the return command to be able to write a good function code

OpenStudy (rsmith6559):

When a function reaches a return statement, it ends the function. A return statement can specify a value to return from the function. If no value is specified, the value None will be returned. More than one return statement can be in a function, but the function ends the first time a return statement is executed. >>> def tf( bool ): ... if( bool ): ... return True ... return ... >>> if( tf( True ) ): ... print "Hello World" ... else: ... print "Goodbye World" ... Hello World >>> if( tf( False ) ): ... print "Hello World" ... else: ... print "Goodbye World" ... Goodbye World >>>

OpenStudy (anonymous):

tnx for the well detailed explanation just what i needed

OpenStudy (rsmith6559):

You're very welcome!

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!