Changes

Jump to: navigation, search

OPS435 Python Lab 3

60 bytes added, 09:12, 2 June 2017
PART 2 - Providing Functions With Arguments
ipython3
</source>When passing arguments up to functions, you MUST contain data such as '''strings''', '''numbers''', or '''variable names''' within '''brackets''' immediately following the function name.<br><br>'''NOTE:''' Normally, when a function is declared that accepts arguments, those '''arguments must be declared''' (using variable names). Those declared variable names are then used within the function for processing. Also, when you call a function with arguments, the number of arguments passed up to the function must correspond (match) the number of arguments that were specified in the function declaration.<br><br>
:#Enter Issue the following from the ipython shell to declare the a function called '''square()''':<source>
def square(number):
return number ** 2
square(12)
square(square(2))
</source>Providing more than one argument in a function requires the use of Multiple arguments are separated by '''commas'''. Be careful NOT to provide strings (without using quotes) or using numbers that use decimalsin these examples, as you may cause errors.<br><br>
:#Issue the following to declare the function '''sum_numbers()''':<source>
def sum_numbers(number1, number2):
13,420
edits

Navigation menu