Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

## DO NOT DELETE THIS # from IPython.display import display, Image, svG, Math, YouTubeVideo QUESTIONS This homework contains a single but challenging question from your

image text in transcribedimage text in transcribed

## DO NOT DELETE THIS # from IPython.display import display, Image, svG, Math, YouTubeVideo QUESTIONS This homework contains a single but challenging question from your textbook. Best of luck. %%file assignment.py class Assignment: def __init_( self, name, ident): self.name = name self.ident = ident def _str_( self ): return f"{self.name}: {self.ident:03d}" Writing assignment.py from assignment import Assignment a = Assignment( "Homework", 1) print( a ) Homework: 001 As you see, the first code cell above used %%file assignment.py to store the content of that cell in an external file called assignment.py Then in the next cell we used an import statement to import what we need to use in our test code. You can always copy and paste code into cells and not use the file magic facility as well. As you know, you have always been asked to never wait for a homework to push you to test all code in the book. In other words, you are expected to enter the code in the book into a file or a notebook and test it to ensure that it works as expected. The first set of questions in this homework simply ask you to do this. Some ask you to provide additional work. Question 1 Solve PROGRAMMING PROJECT 7.8 by creating a Python program named pfcalc.py using file magic (See instructions at the top of this assignment). Implement your solution so that your program accepts arguments from the command line using sys.argv. Your program should accept a single argument, which will represent the path to the file that will contain the commands that your implemention should be able to interpret. Mode: Command X Ln 1, Col 1 ecc201-fall-2020-2021-hw06.ip Your program should accept a single argument, which will represent the path to the file that will contain the commands that your implemention should be able to interpret. For example, we may have the following commands as mentioned in the question stored in cmds1.dat. %%file cmds1.dat ENTER 12 ENTER 15 MUL RESULT Overwriting cmds1.dat Then you should run your program either from a terminal or from a code cell using the ! directive: >>> !python pfcalc.py cmds1.dat In response, your program should internally compute the result of these commands and print out 180 to the screen. See the example command provided for you further below. ! python pfcalc.py cmds1.dat python: can't open file 'pfcalc.py": [Errno 2] No such file or directory

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Database Systems For Integration Of Media And User Environments 98

Authors: Yahiko Kambayashi, Akifumi Makinouchi, Shunsuke Uemura, Katsumi Tanaka, Yoshifumi Masunaga

1st Edition

9810234368, 978-9810234362

More Books

Students also viewed these Databases questions