Changes

Jump to: navigation, search

OPS435 Python Lab 3

4 bytes removed, 11:45, 2 June 2017
PART 1 - Providing Functions With Arguments
square(square(2))
square('2')
</source><br><br>The last function called will call should produce an '''error message'''. This is caused by sending a '''string''' instead of a number that is processed by the function. By using the int() function, any value passed up by a string by mistake will be converted to an integer number.<br><br>
:#Issue the following to declare the function '''sum_numbers()''':<source>
def sum_numbers(number1, number2):
sum_numbers(5, 10)
sum_numbers(50, 100)
</source>'''NOTE:''' Running functions with multiple arguments is the same. When you put a function as a argument of another function, the '''inner-most function will run first''', and the return the value '''10''' from the will be used as the argument for the '''outer function'''. In the example below, '''sum_numbers(5, 5)''' will return '''10''', thus providing that result to be square with that value '''square( 10 )'''.<br><br>
:#Issue the following to issue a function within another function:<source>
square(sum_numbers(5, 5))
13,420
edits

Navigation menu