Literal constants-
A literal is a sequence of one or more
characters that stands for itself.
The numbers such as 2,51,100.12 are literal
constant as value of its is constant.
Also strings such as “Welcome to Python
tutorial” are also literal constants.
Numeric Literals
A numeric literal is a literal
containing only the digits 0–9, an optional sign character (1 or 2), and a possible
decimal point. (The letter e is also used in exponential notation, shown in the
next
subsection). If a numeric literal contains a
decimal point, then it denotes a floating-point value, or “float”
(e.g., 10.24); otherwise, it denotes an integer value (e.g., 10). Commas
are never used in numeric literals.
The numbers such as -2, +51, 100.12, -100.12
Limits of Range in Floating-Point
Representation
There is no limit to the size of an integer
that can be represented in Python. Floating-point values,
however, have both a limited range and a
limited precision. Python uses a double-precision standard format (IEEE 754)
providing a range of 10 2 308 to 10 308 with 16 to 17 digits of precision. To
denote such a range of values, floating-points can be represented in scientific
notation.
Arithmetic overflow occurs when a calculated result is too large
in magnitude to be represented.
Arithmetic underflow occurs when a calculated result is too small
in magnitude to be represented.
String Literals:
Numerical values are not the only literal
values in programming. String literals, or “strings,” represent a
sequence of characters,
'Hello' 'Smith, John' "Baltimore,
Maryland 21210"
In Python, string literals may be delimited (surrounded)
by a matching pair of either single (') or
double (") quotes. Strings must be
contained all on one line (except when delimited by triple quotes). We have
already seen the use of strings in Chapter 1 for displaying screen output,
... print ('Welcome to Python!')
Welcome to Python!
No comments:
Post a Comment