Online Classes - Computer course
Online Classes - Computer course
Arithmetic Operators
Operator Operation Expression English description Result
+ addition 11 + 56 11 plus 56 67
* multiplication 4 * 5 4 multiplied by 5 20
A type is a set of values and operations that can be performed on those values.
● int: integer
For example: 3, 4, 894, 0, -3, -18
● float: floating point number (an approximation to a real number)
For example: 5.6, 7.342, 53452.0, 0.0, -89.34, -9.5
When multiple operators are combined in a single expression, the operations are evaluated in
order of precedence.
Operator Precedenc
e
** highest
- (negation)
*, /, //, %
Errors
A syntax error occurs when we an instruction with invalid syntax is executed. For example:
>>> 3) + 2 * 4
SyntaxError: invalid syntax
A semantic error occurs when an instruction with invalid semantics is executed. For example:
>>> 89.4 / 0
Traceback (most recent call last):
File "", line 1, in
89.4 / 0
ZeroDivisionError: float division by zero
For the purpose of this course, you may think of computer memory as a long list of storage
locations where each location is identified with a unique number and each location houses a
value. This unique number is called a memory address. Typically, we will write memory
addresses as a number with an "id" as a prefix to distinguish them from other numbers (for
example, id201 is memory address 201).
Variables are a way to keep track of values stored in computer memory. A variable is a named
location in computer memory. Python keeps variables in a separate list from values. A variable
will contain a memory address, and that memory address contains the value. The variable then
refers to the value. Python will pick the memory addresses for you.
Terminology