mixed-type arithmetic
Arithmetic combining an int and a float, where Python converts the int to a float so the result is a float.
In more detail
3 + 0.5 is 3.5 and 2 * 3.0 is 6.0. The rule is that the result has the wider of the two types. Numbers and strings never mix automatically; that raises TypeError.
Related terms
- integer — A whole number with no fractional part, such as 7, 0 or -12, which Python calls int.
- floating-point number — A number with a fractional part stored in binary, which can only approximate most decimal values.
- TypeError — The exception raised when an operation or function gets a value of the wrong type, such as adding a number to a string.
Taught in
- Strings, Delimiters And Concatenation — Hands-on Python: Complete Video Course & Book
- Floats, Division And Mixed Types — Hands-on Python: Complete Video Course & Book