Arithmetic Operation in Python

kinds of Arithmetic Operation in Python

Symbolexplainationreturn
+Additiondepend on input type
-Subtractiondepend on input type
*Multiplicationdepend on input type
/Divisionreal number
//DivisionInteger
%Remainederreal number
**power ofdepend on input type
andand logic gareT or F
oror logic gateT or F
<less thanT or F
>greater thanT or F
<=less than or equalT or F
>=greater than or equalT or F
==equalT or F

Result

+, -, *, /, //, %, **, <, >, <=, >= table

ABresult
intintint A+B result
intfloatfloat A+B result
intbool-Tint A+1 result
intbool-Fint A+0 result
intnoneTypeError
intStringTypeError
floatbool-Tfloat A+1 result
floatbool-Ffloat A+0 result
floatnoneTypeError
floatStringTypeError
boolnoneTypeError
boolStringTypeError
noneStringTypeError

When computer created and programming language started, 1 was true and 0 was false.

== table

ABresult
intintbool result
intfloatbool result
intboolbool result
intnonebool result
intStringbool result
floatboolbool result
floatnonebool result
floatStringbool result
boolnonebool result
boolStringbool result
noneStringbool result

unlike Java, this is not comparing class. it compare values.

and, or truth table

ABandor
FFFF
FTFT
TFFT
TTTT

As above table, the “and” “or” are for true and false. If you put other type, or gate return B value If you put other type, and gate return A value

 Share!

 
comments powered by Disqus