Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON QUESTIONS This homework contains a single but challenging question from your textbook. Best of luck. B]: %%file assignment.py class Assignment: ident ): def __init_(

PYTHON

image text in transcribedimage text in transcribed

QUESTIONS This homework contains a single but challenging question from your textbook. Best of luck. B]: %%file assignment.py class Assignment: ident ): def __init_( self, name, self.name = name self.ident = ident def _str_( self ): return f"{self.name}: {self.ident:03d}" Writing assignment.py 9]: from assignment import Assignment 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 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

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_2

Step: 3

blur-text-image_3

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

1 2 3 Data Base Techniques

Authors: Dick Andersen

1st Edition

0880223464, 978-0880223461

Students also viewed these Databases questions