Changes

Jump to: navigation, search

OPS435 Python Lab 3

18 bytes added, 09:36, 3 June 2017
PART 2 - Manipulating Items in Lists
dir(courses)
help(courses)
</source>Below are some examples of using functions to '''manipulate ''' lists. Take time to see how each function can be a useful tool for making changes to existing lists.<br><br>
:#Issue the following:<source>
help(courses.append)
sorted_courses
</source>In addition to using functions to manipulate lists, there are functions that are useful to provide '''information ''' regarding the list such as number of elements in a list, the smallest value and largest value in a list.<br><br>
:#Issue the following:<source>
list_of_numbers = [ 1, 5, 2, 6, 8, 5, 10, 2 ]
min(list_of_numbers) # Returns the smallest value in the list
max(list_of_numbers) # Returns the largest value in the list
</source>In addition to manipulating and obtaining characteristics of a list, it is also useful to be able to '''perform searches ''' for values within lists and obtain the location of values for elements contained within a list. The '''index()''' function allows searching inside a list for a value, it will return the index number of the first occurence. <source>
number = 10
help(list_of_numbers.index)
13,420
edits

Navigation menu