Skip to content

Instantly share code, notes, and snippets.

@algotruneman
Created June 30, 2013 17:56
Show Gist options
  • Save algotruneman/5896171 to your computer and use it in GitHub Desktop.
Save algotruneman/5896171 to your computer and use it in GitHub Desktop.
Practice with: loops, ord and chr to understand Upper and Lower case ASCII codes.
#######################################
#
# asciiplay.py
# Algot Runeman
# November 11, 2012
# June 30, 2013 (reversed order of list)
#
#######################################
a = 'Jones'
for i in range(0,len(a)):
print a[i]
if ord(a[i]) > 64 and ord(a[i]) < 92:
print "upper"
# cause an intentional break in the program
#import sys
# sys.exit("Error message")
# Upper case is chr(65) to chr(91)
for l in range(65, 91):
print l, chr(l),
print '\nUpper and case'
print 'with their ascii values.'
# lower case is chr(97) through chr(122)
for l in range(97, 123):
print chr(l-32), l-32, ':', l, chr(l)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment