Skip to main content

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:

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

from PolStringConvertor import isExpressionValid

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

2. Convert Infix to Postfix

from PolStringConvertor import infixToPostfix

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

3. Convert Infix to Prefix

from PolStringConvertor import infixToPrefix

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

4. Evaluate a Postfix Expression

from PolStringConvertor import evaluatePostfixExpression

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

5. Import All Functions at once

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

Source Code:

Github Link

License

This project is licensed under the MIT License.

Metadata

Release files for PolStringConvertor 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PolStringConvertor 1.0.0
File Size Uploaded
polstringconvertor-1.0.0.tar.gz 4.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PolStringConvertor 1.0.0
File Interpreter ABI Platform
PolStringConvertor-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.8 kB

Release files / polstringconvertor-1.0.0.tar.gz

Download URL polstringconvertor-1.0.0.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
bdd93c5178fd06419a22726c501a071550b0c2dcd7d0031272338f1425943a2c
BLAKE2b-256 checksum
How to use checksums
5fcf11a22e37c85169fec6c17928b1ae6a61e6f3a5570be8a1e989d13a78d3ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / PolStringConvertor-1.0.0-py3-none-any.whl

Download URL PolStringConvertor-1.0.0-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f1efc56c70a1cc69ad19345a67390bb1dfbace55c0b50341c0b306088fb8a08a
BLAKE2b-256 checksum
How to use checksums
ff4d0eba76ed4058d1e26234d177fb570b0f93a558cd6d1dfb6d03edf939be52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page