Evaluating Numerical Expressions

  • Guided Project
  • 0.2 hours
  • Intermediate
  • Python

Practice using stacks in Python to implement an algorithm that evaluates complex numerical expressions stored as strings.

Overview

In this project, you'll take on the role of a software developer tasked with creating an algorithm to evaluate complex numerical expressions input as strings. The challenge is that the expressions are in infix notation (operators between operands), which computer processors cannot innately handle. Your job is to enable evaluating these expressions. You'll use data structures like stacks and concepts like postfix notation (operators after operands) to solve this. The Shunting-yard algorithm will be implemented to convert expressions from infix to postfix notation. Then you'll evaluate the postfix expressions using stacks. All of this will be implemented in Python. Completing this project will grow your skills in working with stacks, implementing complex algorithms, converting between infix and postfix notation, and evaluating expressions. You'll gain valuable experience for software development roles and enhance your portfolio. Objective: Implement an algorithm using stacks in Python to evaluate complex numerical expressions input as strings.

What You'll Learn

  • Implement complex algorithms using stacks
  • Identify how a computer evaluates numerical expressions

Before You Start

  • Implementing linked lists, queues, and stacks in Python
  • Differentiating between FIFO and LIFO data structures
  • Applying data structures to develop algorithmic solutions to computational problems
  • Recognizing how computers parse and evaluate numerical expressions

Project Steps

12 steps

  1. 1 Introduction
  2. 2 Infix and Postfix Notation
  3. 3 Processing an Operator
  4. 4 Evaluating Postfix Expressions
  5. 5 Operator Precedence in Infix Notation
  6. 6 From Infix to Postfix
  7. 7 Handling Closing Parenthesis
  8. 8 Handling Operators
  9. 9 Handling Numbers
  10. 10 Implementing the Shunting-yard Algorithm
  11. 11 Evaluating Infix expressions
  12. 12 Next Steps

Join 1M+ data learners on Dataquest.

  1. 1

    Create a free account

  2. 2

    Choose a learning path

  3. 3

    Complete exercises and projects

  4. 4

    Advance your career