Convert Decimal to Binary, Decimal to Octal, Decimal to Hexadecimal in python
Number conversions using Python: Let's Convert Decimal to Binary, Decimal to Octal, Decimal to Hexadecimal using python. Using python command line argument and python / python 3 Built-in function.
Python 3 supports a number of different ways of handling command line argument. The Built-in way is to use the sys module.
Copy this code and save it as a .py file. Now open your terminal or command prompt and run the following command . Make sure you are in the same directory where the .py is.
$ python your_file_name.py decimal_value
Sample Input :
$ python converter.py 100
Sample output :
Decimal value: 100 In Binary: 1100100 In Octal: 144 In Hexadecimal: 64
Comments
Leave a comment
You are not LoggedIn but you can comment as an anonymous user which requires manual approval. For better experience please Login.