1. Computing

Beginning Python: Data Types

By

3 of 10

Strings - Part 1

A string literal, or string, holds any combination of letters and numbers you would like it to hold. Any number it holds, however, is not treated like a numerical value but is preserved as if it were a word.

One way to think about the difference between a number as a string and a number as a numeric literal is to consider a credit card. The credit card numbers themselves are an example of an integer value; you can add to them and subtract from their value. The credit card, however, preserves the numbers in a set format, complete with spaces. A string does the same thing. While you can multiply and divide the number of the credit card as an integer, you cannot break up the value by the way it is written. To do that you need a string. In this way, an integer represents a quantity, a string represents a quality.

  1. About.com
  2. Computing
  3. Python

©2014 About.com. All rights reserved.