Lecture 5 - 2/6/11 ECE 364: Software Tools Laboratory...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
2/6/11 1 ECE 364: Software Tools Laboratory Lecture 5 February 7, 2011 Lecturer: Michael Goldfarb 1 Lecture 5 § List manipulation § String manipulation § Basic file I/O § A very brief look at functions § Examples are located at § ~ee364/examples/LEC-05 2
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2/6/11 2 Function Calls § In Python you will see primarily two types of function calls: § Some_function(arg1, … argN) § SomeVar.function(arg1, … argN) § May types (e.g. Lists, Tuples, Strings, Dictionaries etc.) provide functions as part of instances of things. § We will not talk about the differences for a while 3 List Functions and Expressions 4 Item in ListVar True if Item is in the list, False if it is not Item not in ListVar True if Item is not in the list, False if it is len(ListVar) Returns the number of elements in the list max(ListVar) Returns the item with maximum value min(ListVar) Returns the item with minimum value sum(ListVar) Returns the sum of all items in the list ListVar.count(Item) Returns the number of times Item occurs in the list
Background image of page 2
3 List Functions ListVar.append(Item) adds Item to the end of the list ListVar.insert(n, Item) inserts Item at index n in the list ListVar.extend(List_2) appends List_2 to end of ListVar ListVar.pop() removes and returns the last item from the list ListVar.pop(n) removes and returns the n th item from the list del ListVar[n] removes (but does not return) item at index n from the list del ListVar[i:j] removes (but does not return) items i to j-1 from the list del ListVar deletes the entire list 5 List Functions ListVar.sort() sorts the list in-place. Does not return anything.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/26/2011 for the course ECE 364 taught by Professor Niklaselmqvist during the Fall '10 term at Purdue University-West Lafayette.

Page1 / 13

Lecture 5 - 2/6/11 ECE 364: Software Tools Laboratory...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online