Monday 14 May 2012

Strings & Lists with P. Guo's Online Python Tutor


Click to Enlarge Image
Code Listing
#4    --- Data
#4.1 ---  Strings
chapter = "4   ---  Data"
section = "4.1 ---  Strings"
print chapter
print section

string = "'abc is part of this text string'"
print 'Concatenation works with strings:' + 'abc' + 'def ' + string

# 4.2 ---   Lists
section = "4.2 ---   Lists"
print '\n' + section +'\n'

# the following constructs/assigns a list
print "# the following constructs/assigns a list"
print """d_list = ['lists','are', 'a', 'sequence', 'of', 'items',1,2]"""
defining_list = ['lists','are', 'a', 'sequence', 'of', 'items',1,2]
print defining_list

No comments:

Post a Comment