python -- tuple

#test tuple

#define zoo and print len
zoo = ('wolf', 'elephant', 'penguin');
print 'zoo len = ', len(zoo), '\n';

new_zoo = ('monkey', 'dolphin', zoo);
print 'new_zoo len = ', len(new_zoo), '\n';

#print tuple
print 'zoo element:\n', zoo, '\n';
print 'new_zoo element:\n', new_zoo, '\n';

print 'zoo[2]:', zoo[2], '\n';
print 'new_zoo[2][2]:', new_zoo[2][2], '\n';

#use print example
strName = 'andylin';
nAge = 28;
print '%s is %d year old\n' %(strName, nAge);
print 'why is %s playing with that python?\n' %strName;

#print tuple
print 'zoo element %s, %s, %s\n' %zoo;
print 'new_zoo element %s, %s, %s\n' %new_zoo;
 

你可能感兴趣的:(python)