Flashcards
SCC212 - Python things
Flashcards do conjunto (15)
- 1Python tings coming upg
- 2The range function can accept three parameters e.g. range(x, y, z) what does each represent respectivelyx = start: Starting number of the sequence.
y = stop: Generate numbers up to, but not including this number.
z = step: Difference between each number in the sequence. - 3What does filter() do?filter(function, sequence) returns a list consisting of those
items from the sequence for which function(item) is true. - 4What does map() do?map(function, sequence) calls the function for each item in
the sequence and returns a list of the resulting values. - 5What does reduce() do?reduce(function, sequence) returns a single value from a sequence of values
- 6TupleTuple = ('red', 'green')
can access like array
tuple[1]
Immutable - 7Nested sequencesscores =[(“Lynn”,759),(“John”,678), (“Chris”,798), (“Mary”,800)]
Tuples inside of lists - 8Dictionariesmutable
Can store any number of objects, including list/tuples
dict1 = { 'abc': 123, 98.6: 37 }
Key is separated from it's value with a colon
Keys are unique - 9String indexinguse -number to index backwards
s[-2]
the actual number to index forwards - 10SlicingWay to extract entire section in a single step
s[1:3]
Slice of s from offsets 1 through 2 (not 3)
s[1:]
Everything past the first (1:len(s)) - 11StringsImmutable
every string operation is defined to produce a new string as its results - 12Listsl = [item1, item2, item3]
no fixed size, no fixed data type - 13Lists comprehensionM = [ [1,2,3],
[4,5,6],
[7,8,9] ] - 14Simple exception handlingtry:
except: - 15Lambdalambda x, y, z: x + y + z
lambda argument, argument2, argumentn: expression
using arguments
Informações
- Descrição
- FlashCards sobre SCC212 - Python things, criado por Mac Howarth em 15-05-2017.
- Criado por
- Mac Howarth
- Visualizações
- 4
- Avaliação