2 Key takeaways Flashcards
notations for representing some fixed values in code. Python has various types of literals - for example, a literal can be a number (numeric literals, e.g., 123), or a string (string literals, e.g., “I am a literal.”).
Literals
system of numbers that employs 2 as the base. Therefore, a binary number is made up of 0s and 1s only, e.g., 1010 is 10 in decimal.
binary system
Octal and Hexadecimal facts
Octal and hexadecimal numeration systems, similarly, employ 8 and 16 as their bases respectively. The hexadecimal system uses the decimal numbers and six extra letters.
Integers (or simply ints) are one of the numerical types supported by Python
They are numbers written without a fractional component, e.g., 256, or -1 (negative integers).
one of the numerical types supported by Python. They are numbers that contain (or are able to contain) a fractional component, e.g., 1.27.
Floating-point numbers (or simply floats)
To encode quote inside a string you can either use
escape character, e.g., ‘I'm happy.’, or open and close the string using an opposite set of symbols to the ones you wish to encode, e.g., “I’m happy.”
to encode an apostrophe, and ‘He said “Python”, not “typhoon”’ to encode a (double) quote.
apostophre
two constant objects True and False used to represent truth values (in numeric contexts 1 is True, while 0 is False.
Boolean Values
There is one more, special literal that is used in Python: the None literal. This literal is a so-called NoneType object, and it is used to represent
the absence of a value
“Hello “, “007”
strings/string literals.
“1.5”
2.0
528
False
The first is a string,
second is a numerical literal (a float),
third is a numerical literal (an integer),
fourth is a boolean literal.
What is the decimal value of the following binary number?
1011
It’s 11, because
(20) + (21) + (2**3) = 11
symbol of the programming language, which is able to operate on the values.
operator
For example, just as in arithmetic, the + (plus) sign is the operator which is able to add two numbers, giving the result of the addition.
operators which are associated with the most widely recognizable arithmetic operations:
+, -, *, /, //, %, **
Please excuse my dear aunt sally
parentheses
exponents
multiplication
division
addition
subtraction
data and operators when connected toghether form
expressions. The simplest expression is a literal itself.