NumPy Input and Output: base_repr() function
numpy.base_repr() function
The base_repr() function is used to get a string representation of a number in the given base system.
Syntax:
numpy.base_repr(number, base=2, padding=0)
Version: 1.15.0
Parameter:
Name | Description | Required / Optional |
---|---|---|
number | The value to convert. Positive and negative values are handled. int |
Required |
base | Convert number to the base number system. The valid range is 2-36, the default value is 2. int |
Optional |
padding | Number of zeros padded on the left. Default is 0 (no padding). int |
Optional |
Returns: out : str
String representation of number in base system.
NumPy.base_repr() method Example:
>>> import numpy as np
>>> np.base_repr(7)
Output:
'111'
NumPy.base_repr() method Example:
>>> import numpy as np
>>> np.base_repr(5, 5)
Output:
'10'
NumPy.base_repr() method Example:
>>> import numpy as np
>>> np.base_repr(5, base=5, padding=3)
Output:
'00010'
NumPy.base_repr() method Example:
>>> import numpy as np
>>> np.base_repr(12, base=16)
Output:
'C'
NumPy.base_repr() method Example:
>>> import numpy as np
>>> np.base_repr(34, base=16)
Output:
'22'
Python - NumPy Code Editor:
Previous: binary_repr() function
Next: datasource() function
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook