{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

CS 1301 Recitation 9 10_20

CS 1301 Recitation 9 10_20 - • f.readline reads one line...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
ASCII stuff (ord, char) Ord/chr – enables you to transform from integer to character. Ord converts strings to integers. Chr converts integers into strings. String methods upper makes letter uppercase lower makes letter lowercase endswith returns true or false if it ends with that string. E.g. a.endswith(“a”) startswith returns true or false if it begins with that string. E.g. a.startswith(“a”) strip strips all white spaces of string w/o a parameter. w/ a parameter, it strips the parameter. find returns the index of the first occurrence of a character found in a string rfind returns the index of the last occurrence of a character in a string List methods append adds to the very end of the list. E.g. aList.append() sort sorts a list. E.g. aList.sort() index is the same as find for strings. Returns the index of the first occurrence of a character in a list. aList.index() Loops Foor While Nested File I/O: readline, readlines f.read gives you the string representation of an entire file
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: • f.readline reads one line of the file • if you do f.readline it reads first line and if u do f.read after it just reads rest of lines. • f.readlines reads every line and returns it as a list. • enter is represented by \n • Open and close files Lists, aliasing vs. cloning • b=a points b to the same copy of the data in a • b=a[:] clones the file. Creates a new copy for b that is the same as a. Two-dimensional arrays (list within a list) • indexing • splicing Sorts: merge, bubble, selection, quick, insertion • know how a sort will operate on a list Searches: binary and sequential big O – measures the amount of work a function does in relation to the number of elements (n) there are in a list • bubble – O(n 2 ) • insertion – O(n 2 ) • merge – O(n log n) • selection – O(n 2 ) • quick – O(nlogn) • binary – O(logn) • sequential – O(n)...
View Full Document

{[ snackBarMessage ]}