Skip to content
/ Number_converter Public template

A Python program for number conversions with a menu-driven interface. It allows setting a number and base, and converting it to binary, octal, hexadecimal, and decimal. Includes error handling for invalid inputs and uses colorama for colorful output in the terminal, enhancing user interaction.

License

Notifications You must be signed in to change notification settings

nishuR31/Number_converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Number Conversion Tool

Overview

This Python program is a command-line tool for converting numbers between binary, octal, hexadecimal, and decimal formats. It provides a menu-driven interface allowing users to set a number and base, and perform conversions. The program uses the colorama library to enhance terminal output with color and includes error handling for invalid inputs.

Features

  • Set a number (or use a random number).
  • Set the base for conversions (2 for binary, 8 for octal, 10 for decimal, 16 for hexadecimal).
  • Convert numbers to binary, octal, hexadecimal, and decimal formats.
  • Colorful terminal output using colorama.
  • Robust error handling for user inputs.

GitHub Repo Size Sponsor Me Open Source Love Follow Me Custom Badge Issue Count Issue Count

Installation

  1. Clone the Repository:

    git clone https://github.com/nishuR31/Number_converter.git
    cd Number_converter
  2. Install Dependencies: Make sure you have Python installed, then install the required packages using pip:

    pip install colorama

    or

    pip install -r requirements.txt

Usage

  1. Run the Program:

    python converter.py

    python -u "converter.py"
  2. Menu Options:

    • 1. Set Number: Enter a number or let the program use a random value.
    • 2. Set Base: Enter the base for conversion (2, 8, 10, 16).
    • 3. Convert to Binary: Convert the number to binary.
    • 4. Convert to Octal: Convert the number to octal.
    • 5. Convert to Hexadecimal: Convert the number to hexadecimal.
    • 6. Convert to Decimal: Display the decimal value of the number.
    • 7. Exit: Exit the program.
  3. Example Interaction:

    Menu:
    1. Set Number
    2. Set Base
    3. Convert to Binary
    4. Convert to Octal
    5. Convert to Hexadecimal
    6. Convert to Decimal
    7. Exit
    
    Choose an option: 1
    
    Enter your number or we'll take random: 42
    Number set to: 42
    
    Choose an option: 3
    
    Binary value of 42 with base 10 is 0b101010
    
    Choose an option: 7
    
    Exiting the program. Goodbye!
    

Error Handling

  • Invalid inputs for numbers or bases are handled with appropriate error messages.
  • Base must be one of the following values: 2, 8, 10, or 16.

Readme Card

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Feel free to submit issues and pull requests to enhance the functionality or fix bugs.

Contact

For questions or suggestions, please contact nishanrajak7679@gmail.com or Github.

About

A Python program for number conversions with a menu-driven interface. It allows setting a number and base, and converting it to binary, octal, hexadecimal, and decimal. Includes error handling for invalid inputs and uses colorama for colorful output in the terminal, enhancing user interaction.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages