[Verba] Coding

Stuart D. Gathman stuart at gathman.org
Thu Jan 12 22:00:25 EST 2006


In our last project, we used "strings".  What is so special about a 
string?  How does it store letters instead of numbers?

Answer: it doesn't.  String store numbers.  A string in python is a 
sequence of 8-bit bytes - i.e. a sequence of numbers where each number has 
a value from 0 to 255.  Python applications (and other languages) often
use strings (sequences of bytes) to represent many other things.  For
instance, a 32-bit number can be stored in a 4 byte string by extracting 
the digits base 256.  The string type in python displays its byte values 
differently than the number types - but the byte values are the same.  You
can convert between string and number types:

>>> char(65)
'A'
>>> ord('A')
65

The particular convention associating number with letters used by
Windows, Unix, and Mac is called ASCII.  The sucessor to ASCII,
called Unicode, associates letters from every language on earth with 16-bit
numbers.

You will thoroughly understand coding after finishing this thick
but entertaining book:

G÷del, Escher, Bach: An Eternal Golden Braid
http://www.amazon.com/gp/product/0465026567/

Within you will find history, dialogs, drawings, music, genetics,
and mathematical proofs.  Genetics?  Yes, the ultimate example
of the power of coding.

Until G÷del, computers worked with numbers.  Babbage called his
calculating engine a "loom for numbers".  G÷del realized that
numbers could represent arbitrary symbols - and this was the
basis of his proof of G÷del's Theorem (that no consistent mathematical
system is capable of describing all mathematical truth).  Now we
take for granted that computers can work with symbols, sound, pictures,
and more.

-- 
	      Stuart D. Gathman <stuart at bmsi.com>
Business Management Systems Inc.  Phone: 703 591-0911 Fax: 703 591-6154
"Confutatis maledictis, flamis acribus addictis" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.




More information about the Verba mailing list