the answer is simpleespecially if you've used almost any other language beforein mixed-type numeric expressionspython first converts operands up to the type of the most complicated operandand then performs the math on same-type operands this behavior is similar to type conversions in the language python ranks the complexity of numeric types like sointegers are simpler than floatingpoint numberswhich are simpler than complex numbers sowhen an integer is mixed with floating pointas in the preceding examplethe integer is converted up to floating-point value firstand floating-point math yields the floating-point result integer to floatfloat math/result similarlyany mixed-type expression where one operand is complex number results in the other operand being converted up to complex numberand the expression yields complex result in python xnormal integers are also converted to long integers whenever their values are too large to fit in normal integerin xintegers subsume longs entirely you can force the issue by calling built-in functions to convert types manuallyint( float( truncates float to integer converts integer to float howeveryou won' usually need to do thisbecause python automatically converts up to the more complex type within an expressionthe results are normally what you want alsokeep in mind that all these mixed-type conversions apply only when mixing numeric types ( an integer and floating pointin an expressionincluding those using numeric and comparison operators in generalpython does not convert across any other type boundaries automatically adding string to an integerfor exampleresults in an errorunless you manually convert one or the otherwatch for an example when we meet strings in in python xnonnumeric mixed types can be comparedbut no conversions are performed--mixed types compare according to rule that seems deterministic but not aesthetically pleasingit compares the string names of the objectstypes in xnonnumeric mixed-type magnitude comparisons are never allowed and raise exceptions note that this applies to comparison operators such as onlyother operators like do not allow mixed nonnumeric types in either or numeric types