15.04.2013 Views

Core Python Programming (2nd Edition)

Core Python Programming (2nd Edition)

Core Python Programming (2nd Edition)

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Numeric Type Operators and Functions<br />

Table B.3 represents the operators and (built-in and factory) functions that apply to <strong>Python</strong>'s numeric<br />

objects.<br />

Table B.3. Operators and Built-in Functions for All Numeric Types<br />

Operator/built-in Description int long float complex Result [a]<br />

abs() Absolute value • • • •<br />

chr() Character • • str<br />

coerce() Numeric coercion • • • • tuple<br />

number [a]<br />

complex() Complex factory function • • • • complex<br />

divmod() Division/modulo • • • • tuple<br />

float() Float factory function • • • • float<br />

hex() Hexadecimal string • • str<br />

int() Int factory function • • • • int<br />

long() Long factory function • • • • long<br />

oct() Octal string • • str<br />

ord() Ordinal (string) int<br />

pow() Exponentiation • • • • number<br />

round() Float rounding • float<br />

[b] Exponentiation • • • • number<br />

**<br />

+ [c] No change • • • • number<br />

- [c] Negation • • • • number<br />

~ [c] Bit inversion • • int/long<br />

[b] Exponentiation • • • • number<br />

**<br />

* Multiplication • • • • number<br />

/ Classic or true division • • • • number<br />

// Floor division • • • • number

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!