Python: Operações com Arrays: Difference between revisions
No edit summary |
|||
(One intermediate revision by the same user not shown) | |||
Line 25: | Line 25: | ||
print(newArray) | print(newArray) | ||
# array('i', [14, 18, 12, 10]) | # array('i', [14, 18, 12, 10]) | ||
= Ver também = | = Ver também = |
Latest revision as of 02:41, 28 September 2018
Arrays em python só podem ser de apenas um tipo
Operações com Arrays
Básico
#!/usr/bin/python from array import * vals = array('i',[5,9,6,7]) print vals # array('i', [5, 6, 9, 7]) print vals[0] # 5 vals.reverse() print vals # array('i', [7, 9, 6, 5]) for v in vals: print(v,end='') # 7965 newArray = array(vals.typecode, (v*2 for v in vals)) print(newArray) # array('i', [14, 18, 12, 10])