From c11b18fed8b287f77acac164a7bfc6bf3e0c5383 Mon Sep 17 00:00:00 2001 From: Arijit De Date: Wed, 23 Aug 2023 16:33:01 +0530 Subject: [PATCH] Fixes #8754, #8724 Updated postfix_evaluation.py postfix_evaluation.py now supports Unary operators and floating point numbers. Also merged evaluate_postfix_notations.py and postfix_evaluation.py into postfix_evaluation.py which fixes #8724. Added a doctest example with unary operator and invalid expression. --- data_structures/stacks/postfix_evaluation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data_structures/stacks/postfix_evaluation.py b/data_structures/stacks/postfix_evaluation.py index c3a0024f4..dc8fd1922 100644 --- a/data_structures/stacks/postfix_evaluation.py +++ b/data_structures/stacks/postfix_evaluation.py @@ -31,7 +31,7 @@ UNARY_OP_SYMBOLS = ("-", "+") BINARY_OP_SYMBOLS = ("-", "+", "*", "^", "/") -def parse_token(token: str | float) -> float | str: +def parse_token(token: str) -> float | str: """ Converts the given data to appropriate number if it is indeed a number, else returns the data as it is with a False flag. This function also serves as a check of whether @@ -39,7 +39,7 @@ def parse_token(token: str | float) -> float | str: Parameters ---------- - token : str or float + token : str The data which needs to be converted to the appropriate number Returns @@ -63,7 +63,7 @@ def is_operator(token: str | float) -> bool: Parameters ---------- - token : str + token : str or float The value that needs to be checked for operator Returns