[SOLVED] CSCI312 Homework 1- Working with Python Parse Trees

25.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon hw01pythonAST-ivfab2.zip (114.4 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
5/5 - (2 votes)

CSCI 312 Homework 1
File names: Names of files and variables, when specified, must be EXACTLY as specified. This includes simple mistakes such as capitalization.
Project: Use the Python AST module to make four programs that handle arithmetic expressions, as follows:
>>> postfix(’2 + (3 * 4) ** 5’)
’2 3 4 * 5 ** +’
>>> infix(’2 + (3 * 4) ** 5’)
’(2+((3*4)**5))’
>>> prefix(’2 + (3 * 4) ** 5’)
’+ 2 ** * 3 4 5’
>>> calc(’2 + (3 * 4) ** 5’)
248834
1
2
3
4
5
6
7
8
The infix should be fully parenthesized, so spaces are not needed. The prefix and postfix will have exactly one space between tokens and nothing else.
Also finish the unittest module provided on the website with a more complete set of tests.
Hand in: Two files, ast_homework.py and test_ast_homework.py.
Follow best practices for docstrings, for example, as found here: https://coderslegacy. com/python/best-practices-for-docstrings/
1

  • hw01pythonAST-ivfab2.zip