Detailed Print – CSKC
Sign In

Search

siteicon
Code Learning#PYTHON#8173 Back

Operator and operand concept program

Variables, literals and other entities are connected using some symbols to indicate the basis of the result that will come after operation. For e.g. a+5 will mean that 5 would be added to the value indicated by a. So + is the operator and a and 5 are the operands.

Source Code

		 

Click to open popup

Run Output

5 25.6 Hello 2.5 5.0 30.6 PythonMagic

Notes

  • Auto typed values follow rules of simple operation, numbers operated by simple mathematical operators. 
  • Division / can be performed with a mix of integer and decimal directly without any type conversion.
  • For Integer division we use // operator.
  • Exponentiation is done using ** operator.
  • + for string does the act of concatenation (side by side addition of text)
  • Rules for operator precedence on the right side of the statement are similar to typical BODMAS rule. Specifically for python it can be seen at. Section 6.17 of https://docs.python.org/3/reference/expressions.html?highlight=precedence 


Suggested Filename(s): operator-operand.py