Skip to content

Instantly share code, notes, and snippets.

@kokukuma
Created April 9, 2012 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kokukuma/2344264 to your computer and use it in GitHub Desktop.
Save kokukuma/2344264 to your computer and use it in GitHub Desktop.
#--------------------------------------------
# 1.1
#--------------------------------------------
print
print "1.1"
#
thestring = "karino"
thelist = list(thestring)
print thelist
#
for c in thestring:
print c
#
result = [x for x in thestring]
print result
#
result = map((lambda x: x+'1'), thestring)
print result
#
import sets
magic_chars = sets.Set('abracadabra')
poppins_chars = sets.Set('supercalifragilisticexpialidocious')
print ''.join(magic_chars & poppins_chars)
#--------------------------------------------
# 1.2
#--------------------------------------------
print
print "1.2"
#
print ord('a')
print chr(98)
print repr(unichr(8224))
#
print map(ord, 'ciao')
#
print ''.join(map(chr , range(97,100)))
#--------------------------------------------
# 1.3
#--------------------------------------------
print
print "1.3"
#
def isAString(anobj):
return isinstance(anobj, basestring)
print isAString('karino')
print isAString(123)
#--------------------------------------------
# 1.4
#--------------------------------------------
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment