Sundry Python Info
Sundry Python Info
questions you can ask yourself as you work with the applications:
✓ What do I find distracting about the application?
✓ Which features were easy to use?
✓ Which features were hard to use?
✓ How did the application make it easy to interact with my data?
✓ How would I make the data easier to work with?
✓ What do I hope to achieve with my application that this application
doesn’t provide?
To tell Python when to use bases other than base 10, you add a 0 and a special
letter to the number. For example, 0b100 is the value one-zero-zero in
base 2. Here are the letters you normally use:
✓ b: Base 2
✓ o: Base 8
✓ x: Base 16
It’s also possible to convert numeric values to other bases using the bin(),
oct(), and hex() commands. So, putting everything together, you can see
how to convert between bases using the commands shown in Figure 5-2.
Try the command shown in the figure yourself so that you can see how the
various bases work. Using a different base actually makes things easier in
many situations, and you’ll encounter some of those situations later in the
book. For now, all you really need to know is that integers support different
numeric bases
Integers
Any whole number is an integer. For example, the value 1 is a whole number,
so it’s an integer. On the other hand, 1.0 isn’t a whole number; it has a decimal
part to it, so it’s not an integer. Integers are represented by the int
data type.
Floating-point values
Any number that includes a decimal portion is a floating-point value. For
example, 1.0 has a decimal part, so it’s a floating-point value. Many people get
confused about whole numbers and floating-point numbers, but the difference
is easy to remember. If you see a decimal in the number, then it’s a floatingpoint
value. Python stores floating-point values in the float data type.
Operators are the basis for both control and management of data within
applications. You use operators to define how one piece of data is compared
to another and to modify the information within a single variable. In fact,
operators are essential to performing any sort of math-related task and to
assigning data to variables in the first place