Changes

Jump to: navigation, search

OPS435 Python Lab 3

27 bytes added, 09:10, 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
</source>'''FYI: ''' To square a number in math your multiply using '''number * number''' or use exponents '''number ** 2''' to the power of two. This function takes one argument '''number''', the function will use exponents to multiply the number given by itself. You should notice that the square of the number sent up to the function is returned to the main program (in our case, the ipython3 shell).<br><br>
:#Issue the following to test your '''square()''' function:<source>
square(5)
13,420
edits

Navigation menu