
Python code
Use input data from input file
Output the results in an output file
You will use recursion to convert prefix expressions directly to postfix expressions. You may not use a stack as you did in Lab 1.
Write a program that accepts a prefix expression containing single letter operands and the operators +, -, *, /, and $ (representing exponentiation). Output the corresponding postfix epression. Be sure to discuss why recursion makes sense.
For example, if your input is *AB then output should be AB*. Output of BA* is considered incorrect.
Required input file:
-+ABC
-A+BC
$+-ABC+D-EF
-*A$B+C-DE*EF
**A+BC+C-BA
/A+BC +C*BA
*-*-ABC+BA
/+/A-BC-BA
*$A+BC+C-BA
//A+B0-C+BA
*$A^BC+C-BA
Output file should produce for:
Prefix = -+ABC
AB+C-
or
Prefix = -A+BC
ABC+-
or Prefix = $+-ABC+D-EF
$+-ABC+D-EF
Thanks!

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images

- Need help with Python. Paste indented code QUESTION 8 Implement the following:1) Define a function oddList() with an arbitrary parameter a.2) This function accepts any number of integer arguments.3) oddList() stores all odd numbers into a list and returns the list.4) Call the function with 1, 2, 3, 4, 5 as arguments.5) Print the result of the function call. Example Output[1, 3, 5]arrow_forwardWrite pseudocode for a Python program that 1) defines a list to store the choice of +, -, *, and /, defines functions to support the calculations, and calls them in response to user inputs. Test each of the four calculations, and turn in the pseudocode, the Python program, and a screenshot of your output displaying the four tests in the Python shell.Run your program and test all four calculations,Take a screenshot of your program’s output from the Python shell.arrow_forwardPLEASE SEPARATE EACH SOURCE CODEarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





