PolStringConvertor


NamePolStringConvertor JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/CyberPokemon/PolStringConvertor
SummaryA package to convert infix expressions to postfix/prefix and evaluate them
upload_time2024-10-16 10:00:44
maintainerNone
docs_urlNone
authorImon Mallik
requires_python>=3.6
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# PolStringConvertor

PolStringConvertor is a Python package that provides utilities to convert infix expressions into postfix and prefix forms, and to evaluate postfix expressions. It also includes validation of infix expressions.

## Features

- Validate infix expressions for proper operator placement and balanced parentheses.
- Convert infix expressions to postfix notation.
- Convert infix expressions to prefix notation.
- Evaluate postfix expressions.

## Installation

To install the package, use pip:

```bash
pip install PolStringConvertor
```

This package requires the `StrTokenizer` package version 1.1.0 to function properly. It will be installed automatically when you install `PolStringConvertor`.

## Usage

Here’s how to use the main features of the package:

### 1. Validate an Infix Expression

```python
from PolStringConvertor import isExpressionValid

expression = "(a+b)*c"
print(isExpressionValid(expression))  # Returns True or False
```

### 2. Convert Infix to Postfix

```python
from PolStringConvertor import infixToPostfix

expression = "(a+b)*c"
postfix = infixToPostfix(expression)
print(postfix)  # Output: ['a', 'b', '+', 'c', '*']
```

### 3. Convert Infix to Prefix

```python
from PolStringConvertor import infixToPrefix

expression = "(a+b)*c"
prefix = infixToPrefix(expression)
print(prefix)  # Output: ['*', '+', 'a', 'b', 'c']
```

### 4. Evaluate a Postfix Expression

```python
from PolStringConvertor import evaluatePostfixExpression

postfix = ['3', '4', '+', '2', '*', '7', '/']
result = evaluatePostfixExpression(postfix)
print(result)  # Output: 2.0
```

### 5. Import All Functions at once

```python
from PolStringConvertor import *

expression = "(a+b)*c"
print(isExpressionValid(expression))  # Returns True or False

postfix = infixToPostfix(expression)
print(postfix)  # Output: ['a', 'b', '+', 'c', '*']

prefix = infixToPrefix(expression)
print(prefix)  # Output: ['*', '+', 'a', 'b', 'c']

postfix = ['3', '4', '+', '2', '*', '7', '/']
result = evaluatePostfixExpression(postfix)
print(result)  # Output: 2.0

```

You can install the `PolStringConvertor` package from PyPI:

[Install PolStringConvertor from PyPI](https://pypi.org/project/PolStringConvertor/1.0.0/)

## Source Code:

[Github Link](https://github.com/CyberPokemon/PolStringConvertor)

## License

This project is licensed under the MIT License.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/CyberPokemon/PolStringConvertor",
    "name": "PolStringConvertor",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "Imon Mallik",
    "author_email": "imoncoding@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/5f/cf/11a22e37c85169fec6c17928b1ae6a61e6f3a5570be8a1e989d13a78d3ca/polstringconvertor-1.0.0.tar.gz",
    "platform": null,
    "description": "\r\n# PolStringConvertor\r\n\r\nPolStringConvertor is a Python package that provides utilities to convert infix expressions into postfix and prefix forms, and to evaluate postfix expressions. It also includes validation of infix expressions.\r\n\r\n## Features\r\n\r\n- Validate infix expressions for proper operator placement and balanced parentheses.\r\n- Convert infix expressions to postfix notation.\r\n- Convert infix expressions to prefix notation.\r\n- Evaluate postfix expressions.\r\n\r\n## Installation\r\n\r\nTo install the package, use pip:\r\n\r\n```bash\r\npip install PolStringConvertor\r\n```\r\n\r\nThis package requires the `StrTokenizer` package version 1.1.0 to function properly. It will be installed automatically when you install `PolStringConvertor`.\r\n\r\n## Usage\r\n\r\nHere\u00e2\u20ac\u2122s how to use the main features of the package:\r\n\r\n### 1. Validate an Infix Expression\r\n\r\n```python\r\nfrom PolStringConvertor import isExpressionValid\r\n\r\nexpression = \"(a+b)*c\"\r\nprint(isExpressionValid(expression))  # Returns True or False\r\n```\r\n\r\n### 2. Convert Infix to Postfix\r\n\r\n```python\r\nfrom PolStringConvertor import infixToPostfix\r\n\r\nexpression = \"(a+b)*c\"\r\npostfix = infixToPostfix(expression)\r\nprint(postfix)  # Output: ['a', 'b', '+', 'c', '*']\r\n```\r\n\r\n### 3. Convert Infix to Prefix\r\n\r\n```python\r\nfrom PolStringConvertor import infixToPrefix\r\n\r\nexpression = \"(a+b)*c\"\r\nprefix = infixToPrefix(expression)\r\nprint(prefix)  # Output: ['*', '+', 'a', 'b', 'c']\r\n```\r\n\r\n### 4. Evaluate a Postfix Expression\r\n\r\n```python\r\nfrom PolStringConvertor import evaluatePostfixExpression\r\n\r\npostfix = ['3', '4', '+', '2', '*', '7', '/']\r\nresult = evaluatePostfixExpression(postfix)\r\nprint(result)  # Output: 2.0\r\n```\r\n\r\n### 5. Import All Functions at once\r\n\r\n```python\r\nfrom PolStringConvertor import *\r\n\r\nexpression = \"(a+b)*c\"\r\nprint(isExpressionValid(expression))  # Returns True or False\r\n\r\npostfix = infixToPostfix(expression)\r\nprint(postfix)  # Output: ['a', 'b', '+', 'c', '*']\r\n\r\nprefix = infixToPrefix(expression)\r\nprint(prefix)  # Output: ['*', '+', 'a', 'b', 'c']\r\n\r\npostfix = ['3', '4', '+', '2', '*', '7', '/']\r\nresult = evaluatePostfixExpression(postfix)\r\nprint(result)  # Output: 2.0\r\n\r\n```\r\n\r\nYou can install the `PolStringConvertor` package from PyPI:\r\n\r\n[Install PolStringConvertor from PyPI](https://pypi.org/project/PolStringConvertor/1.0.0/)\r\n\r\n## Source Code:\r\n\r\n[Github Link](https://github.com/CyberPokemon/PolStringConvertor)\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License.\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A package to convert infix expressions to postfix/prefix and evaluate them",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/CyberPokemon/PolStringConvertor"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ff4d0eba76ed4058d1e26234d177fb570b0f93a558cd6d1dfb6d03edf939be52",
                "md5": "0ce7a2f39002b3542b4bbb45d4110057",
                "sha256": "f1efc56c70a1cc69ad19345a67390bb1dfbace55c0b50341c0b306088fb8a08a"
            },
            "downloads": -1,
            "filename": "PolStringConvertor-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0ce7a2f39002b3542b4bbb45d4110057",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 4658,
            "upload_time": "2024-10-16T10:00:43",
            "upload_time_iso_8601": "2024-10-16T10:00:43.237113Z",
            "url": "https://files.pythonhosted.org/packages/ff/4d/0eba76ed4058d1e26234d177fb570b0f93a558cd6d1dfb6d03edf939be52/PolStringConvertor-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5fcf11a22e37c85169fec6c17928b1ae6a61e6f3a5570be8a1e989d13a78d3ca",
                "md5": "4e3299f817e5a1539d73f97c4db64963",
                "sha256": "bdd93c5178fd06419a22726c501a071550b0c2dcd7d0031272338f1425943a2c"
            },
            "downloads": -1,
            "filename": "polstringconvertor-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "4e3299f817e5a1539d73f97c4db64963",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 4097,
            "upload_time": "2024-10-16T10:00:44",
            "upload_time_iso_8601": "2024-10-16T10:00:44.611755Z",
            "url": "https://files.pythonhosted.org/packages/5f/cf/11a22e37c85169fec6c17928b1ae6a61e6f3a5570be8a1e989d13a78d3ca/polstringconvertor-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-16 10:00:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "CyberPokemon",
    "github_project": "PolStringConvertor",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "polstringconvertor"
}
        
Elapsed time: 0.51591s