python学習-list tuple dist set

773 ワード

#  list
T = [[1,2,3],
	[4,5,6],
	[7,8,9]]
col = [row[1] for row in T]
print col
#[2,5,8]
name = ['mic', 123, True]
name[2] = False
print len(name),name
#3 ['mic', 123, False]
#  tuple
tp = ('a', 'b', ['A', 'B'])
tp[2][0] = 'C'
print tp
#('a', 'b', ['C', 'B'])


#dict   
d = {'Michael': 95, 'Bob': 75, 'Tracy': 85}
d['Adam'] = 67
d.pop('Bob')
for i in d:
 print i,d[i]
print d['Adam']
print d.get('Adama')
#set
a = (['a','b','c'])
a[0] = 'abc'
print a
#['abc','b','c'])
#       
n = '1'
n = int(n)
print n