Professional Documents
Culture Documents
MULLAI THIAGU
IFMR, GSB
( DATA505 – PRP )
21 JANUARY, 2023
DATA TYPES AND OPERATORS
Part I: Operators & Operands
Part V: Hands-on
PART I – OPERATORS & OPERANDS
OPERATORS & OPERANDS
In Python, operators are special symbols that designate that
some sort of computation should be performed
Operands ? a, b
Operators ? + =
Category Operators
Arithmetic +, -, *, /, %, //, **
Category Operators
Arithmetic +, -, *, /, %, //, **
Arithmetic +, -, *, /, %, //, **
Arithmetic +, -, *, /, %, //, **
Arithmetic +, -, *, /, %, //, **
Arithmetic +, -, *, /, %, //, **
Arithmetic +, -, *, /, %, //, **
Multiply two
* operands x*y 9 * 5 = 45
Relational
Math
Meaning operator in
symbol
python
Equals = ==
Not equal ≠ !=
Less than < <
Less than or equal ≤ <=
Example: A = 15
Variables:
pi ,
circle_radius,
circle_area
Output
RULES AND NAMING CONVENTION FOR
VARIABLES AND CONSTANTS
Constant and variable names should have a combination of letters
in lowercase (a to z) or uppercase (A to Z) or digits (0 to 9) or an
underscore (_)
Double (“ “)
Triple (‘’’ ‘’’)
1, -3, 5, 10002
Instructions that a
Python interpreter
can execute are
called statements
For example, a = 1
is an assignment
statement
PART III – CREATING EXPRESSIONS
EXPERESSION : EXAMPLE
What is the expected
output ?
A ) 240
B) 60
Operator Precedence
https://realpython.com/python-operators-expressions/
PART IV – COMMENTS
COMMENTS
Comments in source code are another form of note
Add them to the code to remember what task the code performs
A special way to determine the text written in the code does not get
executed by the computer -> ‘Comments’
Z = a + (b * c)
1. https://cs50.harvard.edu/college/2019/fall/notes/0/
2. www.theacademyofcode.com/handouts
3. https://www.skillsyouneed.com/num/polygons.html
4. https://cs50.harvard.edu/college/2019/fall/notes/0/
5. https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/turing-machine
6. https://www.programiz.com/python-programming/variables-constants-literals
7. https://www.programiz.com/python-programming/operators
8. https://www.tutorialspoint.com/python/python_basic_operators.htm
9. https://stackabuse.com/overloading-functions-and-operators-in-python/
10. https://www.w3schools.com/python/ref_math_sin.asp
11. https://www.discogcodingacademy.com/turtle-colours
12. https://www.javatpoint.com/python-turtle-programming
13. https://realpython.com/python-operators-expressions/