Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
20 Cards in this Set
- Front
- Back
strings
|
A data type for representing a sequence of characters.
-get w/ <input()> |
|
string functions
|
+ = concatenates
*n = concatenates n times name[ : ] = splices from : to len() = gives lenght for i in <name>: = iterates through the string Also for python: any <name.> capitalize, center, count, find, join, ljust, lower, lstrip, replace, rfind, rjust, rstrip, split, title, or upper. str() = converts another data type to a string. splice() = converts to a list and chops out where it cuts (default is spaces). |
|
lists
|
A data type representing sequential collections. Heterogeneous and mutable.
|
|
list functions
|
splice: <name[ ]>
concatenate <+> length: <len()> Add to: <'name'.append('item')> |
|
ASCII / Unicode (#s and operations)
|
65-90: uppercase alphabet
97-122: lowercase alphabet ord('x') => produces unicode value chr(#) => produces character for that unicode value |
|
functions
|
A subprogram
|
|
why use functions
|
1)To get code to reflect logical components of problem
2)Prevent repetitive code |
|
function syntax
|
<name('arguments')>
|
|
Ways to pass info out of a subprogram
|
1)use <return> in function and assignment statement in calling function
2)modify a list or data in an object |
|
files and their operations
|
Basically huge character strings.
Need to: 1) open w/ <open('name','r/w')> 2) read w/ <read> (whole file), <readline>(one line up and to \n), <readlines>(rest of lines in file as a list) 3) close w/ <'name'.close()> |
|
simple conditions
|
just an if statement (code only activated if needed)
|
|
compound conditions
|
more than one condition <else> and/or <elif>
|
|
try...except
|
Exception handling, try to avoid errors
|
|
sequences
|
A list of smaller objects: string, list, or file.
|
|
sentinels
|
A variable assigned a value and used in a condition to determine if code should be used.
|
|
Boolean operators and their truth tables
|
and --> only T and T is true
or --> only F or F is false not --> F to T or vice versa importance: not > and > or |
|
Boolean algebra
|
a or (b and c) --> a or b and (a or c)
--distributive for or/and not(a or b) --> (not a) and (not b) --De Morgan's laws = not switches and/or when distributed |
|
simulation
|
Run a model many times when wet lab isn't feasible.
|
|
monte carlo simulation
|
use probability in model.
|
|
random module
|
random() => generates a random number in range 0 to 1
randrange(#,#) => random number in b/t specified numbers |