Product SiteDocumentation Site

Chapter 4. Operators and expressions

4.1. Operators
4.2. Example of integer arithmetic
4.3. Relational Operators
4.4. Logical Operators
4.5. Shorthand Operator
4.6. Expressions
4.7. Type Conversions
4.8. evaluateequ.py
4.9. quadraticequation.py
4.10. salesmansalary.py

In python most of the lines you will write will be expressions. Expressions are made of operators and operands. An expression is like 2 + 3 .

4.1. Operators

Operators are the symbols which tells the python interpreter to do some mathematical or logical operation. Few basic examples of mathematical operators are given below:
        
>>> 2 + 3
5
>>> 23 - 3
20
>>> 22.0 / 12
1.8333333333333333

To get floating result you need to the division using any of operand as floating number. To do modulo operation use % operator
 
>>> 14 % 3
2