Open main menu

CDOT Wiki β

Changes

OPS435 Python Lab 3

497 bytes added, 14:58, 30 May 2017
PART 1 - Using Functions
print('Inside a Function')
</source>
:#Now that our function was created, we can use it over and over. To execute the code inside the function, run the function name with "'''()'''" '''brackets''' at the end of the function name.<br>Try running the '''hello() ''' function by name three times by issuing the following:<source>
hello()
hello()
hello()
</source>You should notice that the function just does the same thing over-and-over no matter how many times your call the function by name. By the way, that is OK. On the other hand, you may want to create and use a function to do something, like perform error checking or some other task that returns a value to the '''main''' program for further processing. For example, a true or false value if the error checking function that was called was detected no errors or detected an error.<br><br>:#Next, Let's create a function that returns some data after the function runsis called. This function does not print out any text, it creates new variables and at the end returns the value.<source>
def return_text_value():
name = 'Terry'
13,420
edits