Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 145 - CodePilot V5.0 C6
P. 145

    21 st
                          INTERDISCIPLINARY LEARNING                                              Century   #Critical Thinking
                                                                                                   Skills

                      Write a Python program to calculate the area of a square.

                                                                                          MATHEMATICS

                            PRECEDENCE OF OPERATORS

                     Operator precedence determines  the order in which operations  are performed.  Operators
                     with higher precedence are evaluated first. When operators have the same precedence, Python
                     evaluates them from left to right (associativity). The following table shows the operator precedence,
                     starting with the highest precedence at the top:

                                        Operator                                       Name
                          ()                                     Parentheses
                          **                                     Exponentiation

                          *, /, //, %                            Multiplication, Division, Floor Division, Modulus
                          +, –                                   Addition, Subtraction
                           <, <=, >, >=, !=, ==                  Relational operators

                          not
                          and                                    Logical operators
                          or

                          =, %=, /=, //=, -=, +=, *=, **=        Assignment operators

                      RAPID RECALL                             Tick ( ) if you know this.

                         1.  A single-line comment begins with the hash symbol (#).

                         2.  Keywords are reserved, so you cannot use them as variable names or identifiers.

                                                                                                                      143
                                                                                                  Python–Start to Code

| 140 141 142 143 144 145 146 147 148 149 150 |