June 2002
Beginner to intermediate
640 pages
14h 24m
English
We've been using literals since Chapter 1, but we didn't call them that. The term is computerspeak for a constant value; that is, what you type is literally what you get. In the following interactive session, for example, the literals are "Hello World", 100, 3200000000000L, and 3.5.
>>> a_literal_string = "Hello World" >>> a_literal_integer = 100 >>> a_literal_long = 3200000000000L >>> a_float_literal = 3.5
Literals can be contained in statements.
print ("Hello I am a literal string")
| Character | Meaning |
|---|---|
| \\ | Backslash |
| \' | Single quote |
| \" | Double quote |
| \a | ASCII Bell (BEL) |
| \b | ASCII Backspace (BS) |
| \f | ASCII Formfeed (FF) |
| \n | ASCII Linefeed (LF) |
| \r | ASCII Carriage return (CR) |
| \t | ASCII Horizontal tab (TAB) ... |
Read now
Unlock full access