Changes

Jump to: navigation, search

OPS435 Python Lab 3

20 bytes removed, 11:24, 3 June 2017
PART 3 - Iterating Over Lists
square(value)
</source>You should see the effectiveness of from the previous demonstrationthe advantage of using lists with functions. Although useful, the demonstration above only prints the squares as opposed to saving them for future use. The next demonstration uses a function that loops through lists, squares the values, but saves the squares in a new list.<br><br>
:#Issue the following:<source>
list_of_numbers = [ 1, 5, 2, 6, 8, 5, 10, 2 ]
</source>
:::*The script should have a '''Shebang line'''
:::*The list '''my_list''' should have the values: '''1, 2, 3, 4, 5'''
:::*The script should have a function called add_item_to_list(my_list)
13,420
edits

Navigation menu