Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/17-Advanced Python Objects and Data Structures/01-Advanced Numbers.ipynb
Views: 648
Advanced Numbers
In this lecture we will learn about a few more representations of numbers in Python.
Hexadecimal
Using the function hex()
you can convert numbers into a hexadecimal format:
Binary
Using the function bin()
you can convert numbers into their binary format.
Exponentials
The function pow()
takes two arguments, equivalent to x^y
. With three arguments it is equivalent to (x^y)%z
, but may be more efficient for long integers.
Absolute Value
The function abs()
returns the absolute value of a number. The argument may be an integer or a floating point number. If the argument is a complex number, its magnitude is returned.
Round
The function round()
will round a number to a given precision in decimal digits (default 0 digits). It does not convert integers to floats.
Python has a built-in math library that is also useful to play around with in case you are ever in need of some mathematical operations. Explore the documentation here!