Home | | Problem Solving and Python Programming | Operators and operands

Python Programming - Operators and operands | Problem Solving and Python Programming : Data, Expressions, Statements

Chapter: Problem Solving and Python Programming : Data, Expressions, Statements

Operators and operands

Operators are special symbols that represent computations like addition and multiplication. The values the operator is applied to are called operands.

Operators and operands

Operators are special symbols that represent computations like addition and multiplication. The values the operator is applied to are called operands.

The operators +, -, *, / and ** perform addition, subtraction, multiplication, division and exponentiation.

Eg:

20+32

hour-1

hour*60+minute

minute/60

5**2 (5+9)*(15-7)

 

Precedence Of Operators

The order of evaluation depends on the rules of precedence. The acronym PEMDAS is a useful way to remember the rules:

·           Parentheses have the highest precedence

·           Exponentiation has the next highest precedence, so 2**1+1 is 3, not 4, and 3*1**3 is 3, not 27.

·           Multiplication and Division have the same precedence, which is higher than Addition and Subtraction, which also have the same precedence. So 2*3-1 is 5, not 4, and 6+4/2 is 8, not 5.

·           Operators with the same precedence are evaluated from left to right.

 

Tags : Python Programming , Problem Solving and Python Programming : Data, Expressions, Statements
Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
Problem Solving and Python Programming : Data, Expressions, Statements : Operators and operands | Python Programming

Related Topics

Problem Solving and Python Programming : Data, Expressions, Statements


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2024 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.