Integers Flashcards
system computers use to store numbers
binary
0 and 1
numbers handled by computers
integers - devoid of fractions
floating-points - contain fractions
The characteristic of the numeric value which determines its kind, range, and application, is called the
type
simply a string of digits that make up the number. But there’s a reservation
like in death becomes her
you must not interject any characters that are not digits inside the number.
in other words you can use underscores but not
commas , 111,111,111 - NAY!!!
dot . 111.111.111 - NAY!!!
spaces 111 111 111 - NAY!!!
underscore 111_111_111 - HOORAH!!!!
no space 111111111 - HOORAH!!!!
Negative numbers are created by adding the - BEFORE the number
You can write: -11111111, or -11_111_111.
HOORAH!!!!!
octal numbers
Doc Oc
0O or 0o prefix (zero-o)
[0..7] range only
0o123 is an octal number with a (decimal) value equal
83
numbers should be preceded by the prefix 0x or 0X (zero-x).
[0..15] range only
hexadecimal
0x123 is a hexadecimal number with a (decimal) value equal to 291. The print() function can manage these values too.
represent and to store the numbers that (as a mathematician would say) have a non-empty decimal fraction.
floats
Whenever we use a term like two and a half or minus zero point four, we think of numbers which the computer considers floating-point numbers:
2.5
-0.4
But don’t forget this simple rule - you can omit zero when it is the only digit in front of or after the decimal point.
In essence, you can write the value 0.4 as:
.4
For example: the value of 4.0 could be written as:
4.
Look at these two numbers:
4
4.0
You may think that they are exactly the same, but Python sees them in a completely different way.
4 is an integer number, whereas 4.0 is a floating-point number.
The point is what makes a float.
it’s not only points that make a float. You can also use the letter e.
When you want to use any numbers that are very large or very small, you can use scientific notation.
Take, for example, the speed of light, expressed in meters per second. Written directly it would look like this: 300000000.
To avoid writing out so many zeros, physics textbooks use an abbreviated form, which you have probably already seen: 3 x 108.
Take, for example, the speed of light, expressed in meters per second. Written directly it would look like this: 300000000.
To avoid writing out so many zeros, physics textbooks use an abbreviated form, which you have probably already seen: 3 x 108.
It reads: three times ten to the power of eight.
In Python, the same effect is achieved in a slightly different way - take a look:
3E8
The letter E (you can also use the lower-case letter e - it comes from the word exponent) is a concise record of the phrase times ten to the power of.
remember this!
the exponent (the value after the E) has to be an integer;
the base (the value in front of the E) may be an integer.