Open main menu

CDOT Wiki β

Changes

OPS435 Python Lab 3

241 bytes removed, 14:31, 30 January 2018
PART 3 - Iterating Over Lists
: You will now learn how to define and run functions that will return '''string data''' when a function is called.
 
:Let's experiment with defining and running functions. Using iPython you can define and run functions in your sesion and call them from the iPython shell to test them out prior to adding them into scripts. You will learn how to do this.
:'''Perform the Following Steps:'''
::The following '''for''' loop will store the value of each element from list_of_numbers within a variable named '''item''' and run code indented below the loop for each item.<br><br>
:#Issue the following in the ipython shellRun this from a temporary Python file:<source lang="python">
list_of_numbers = [ 1, 5, 2, 6, 8, 5, 10, 2 ]
for item in list_of_numbers: