The command line argument implement in python

Assignment Help Python Programming
Reference no: EM132105040

Problem:

Part 1 will be implemented in Python. Program 1 (called prog4_1.py)

-will take a single command line argument. The command line argument will be the name of a text file.

-Your program should then read that file line by line and tokenize each input line, using a space as a delimiter.

-For each tokenized input line, print a single line to stdout each of the tokens separated with a comma. Multiple spaces, and leading/trailing spaces should be ignored.

Part 1 will be run like so: python3 prog4_1.py filename.txt

Part 2. In Python, Implement the class StackMachine in the StackMachine.py file.

-The StackMachine class should have eight member functions: push, pop, add, sub, mul, div, mod and the constructor.

-The push function should be the only member function that takes more than one argument.

-The pop function will be the only member function to return anything. (Each of the functions should take the self reference).

-If an operation is called, but not enough operands are available on the stack, nothing should occur. You can use any built in packages to implement the StackMachine class. You will probably only need a single member variable to implement this.

-push - Takes two arguments, the second argument should be pushed onto to internal data structure. pop - Removes and returns the top element of the internal data structure.

-If nothing is avalible, return None. (None is a valid data type in python). The math functions take only the self reference, if two (or more) elements exist on the internal data structure pop the top two elements off, perform the operations and push the answer onto the top of the internal data structure.

Program 2 will be written in Python. It will be called prog4_2.py

-This program will take a single command line argument which will be the name of a text file.

-The program will tokenize each line of the text file by a space (as performed in prog4_1.py). After tokenization, if the there are two tokens, and the first token is the string "push" and the second token is a number (real numbers are ok) it should push the number onto a StackMachine.

If there is a single token, and it is the string: pop, add, sub, mul, div or mod, the correct function on the StackMachine should be called. In the event of a pop, the returned value should be printed to the stdout. Any other input should be ignored.

You must ensure that your code can be run on a standard Debian based linux distribution using the shell tools of your choice. You may develop your solution on any machine you desire, as long as the final solution works on a standard linux distrubtion.

Reference no: EM132105040

Questions Cloud

What is the net operating income for the month : I do not know where to go after this?? What is the net operating income for the month under absorption costing?
What is the company margin of safety in dollars : What is the company's margin of safety in dollars?
Write a class that verifies that a password meets : Write a class that verifies that a password meets the stated criteria. Demonstrate the class in a program that allows the user to enter a password.
How are the large losses related to fixed costs : How are the large losses related to fixed costs? Identity a way that John can turn potential fixed costs into variable costs.
The command line argument implement in python : The StackMachine class should have eight member functions: push, pop, add, sub, mul, div, mod and the constructor.
Purchasing power of money in the us : Who is responsible for sustaining the purchasing power of money in the US?
Npv estimated using cash flows : Would it expected that the NPV based on net revenue/income to be greater or lesser than the NPV estimated using cash flows?
Main purpose of a flexible budget : What might be the main purpose of a flexible budget for managers and how is it important for managerial decision.
How is managerial economics important : How is managerial economics important in the determination-making process of an organization or business?

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd