In this assignment, you will write a Python program which reads a text file that associates...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
In this assignment, you will write a Python program which reads a text file that associates languages with their ISO codes and character sets, and outputs the requested information. (Just in case you are curious, a list of ISO codes can be found here: https://en.wikipedia.org/wiki/List_of_ISO 639- 1_codes, and a list of sets can be found here: https://en.wikipedia.org/wiki/Character_encoding, but they are not required for the assignment). These are the specifications for your Python program: It must be named languages.py It should be invoked as: python languages.py option argument_file In the command line above, option means one of the options described below, and argument_file means the chosen argument file, which can have any arbitrary name. 1. 2. The program must check that argument argument_file exists, is a file and is readable. If not, it must print an error message to the standard output and exit. The specifications for the argument_file and option arguments are given below. 3. File argument_file can have any arbitrary name. It must be a file of text with the following format: a. The file consists of an arbitrary number of lines (including, possibly, zero lines). b. Each line must contain three fields separated by one or more space characters. c. The three fields are: name, code, set. d. The name field is a string of characters representing the name of a language. e. The code field is a string of two characters representing the ISO code for the language. f. The set field is a string of characters representing the character set for the language. Fundamental note: your program is not expected to verify that file argument_file complies with the above specifications. It will only be tested with compliant files. The following example should be regarded as the reference specification for the format of file argument_file: German de ISO-8859-1 English en ISO-8859-1 Chinese zh GB2312 4. English en ISO-885 Chinese zh GB2312 Italian it ISO-8859-1 Japanese ja EUC-JP Korean Hindi ko hi UTF-8 Vietnamese vi UTF-8 EUC-KR Your program can be invoked with option: -a. In this case, it must print all the language names in file argument_file in alphabetical order, in this format: Languages in this file: first 3 name in alphabetical order 4. Vietnamese vi UTF-8 Your program can be invoked with option: -a. In this case, it must print all the language names in file argument_file in alphabetical order, in this format: Languages in this file: first name in alphabetical order second name in alphabetical order last name in alphabetical order Example with file argument_file given above: Command line: python languages.py -a argument file Expected output: Languages in this file: Chinese English German Hindi Italian Janan 5. Korean Vietnamese In the case in which file argument_file is empty, your program must instead only print: No languages in this file Your program can be invoked with option: -c code. The code argument has the same format as the code field in the argument file. In this case, your program must search for the code in the argument file, and if it finds it, print the language name. This is an example with file argument_file given above: Command line: python languages.py -c it argument_file Expected output: Italian In the case in which your program cannot find the given code in the argument file (including the case where the argument file is empty), it must print: 6. Code code not present in this file Example with file argument_file given above: Command line: python languages.py -c fr argument_file Expected output: Code fr not present in this file Your program can be invoked with option: -s set. The set argument has the same format as the set field in the argument file. In this case, your program must search for all the matches between the set argument and the set field in the argument file, and print all the corresponding language names, in the order in which they appear in the file. This is an example with file argument_file given above: Command line: python languages.py s ISO-8859-1 argument_file Expected output: 7. 8. English Italian In the case in which your program cannot find the given set in the argument file (including the case where the argument file is empty), it must print: Character set set not present in this file Example with file argument_file given above: Command line: python languages.py -s ISO-8859-7 argument_file Expected output: Character set ISO-8859-7 not present in this file Your program can be invoked with option: -v. In this case, it must only print your name, surname, student ID and date of completion of your assignment, in a format of your choice. Please note that argument argument file is still required. No options can be used simultaneously. This means that your program can only be invoked with one of the options at a time. L3 In this assignment, you will write a Python program which reads a text file that associates languages with their ISO codes and character sets, and outputs the requested information. (Just in case you are curious, a list of ISO codes can be found here: https://en.wikipedia.org/wiki/List_of_ISO 639- 1_codes, and a list of sets can be found here: https://en.wikipedia.org/wiki/Character_encoding, but they are not required for the assignment). These are the specifications for your Python program: It must be named languages.py It should be invoked as: python languages.py option argument_file In the command line above, option means one of the options described below, and argument_file means the chosen argument file, which can have any arbitrary name. 1. 2. The program must check that argument argument_file exists, is a file and is readable. If not, it must print an error message to the standard output and exit. The specifications for the argument_file and option arguments are given below. 3. File argument_file can have any arbitrary name. It must be a file of text with the following format: a. The file consists of an arbitrary number of lines (including, possibly, zero lines). b. Each line must contain three fields separated by one or more space characters. c. The three fields are: name, code, set. d. The name field is a string of characters representing the name of a language. e. The code field is a string of two characters representing the ISO code for the language. f. The set field is a string of characters representing the character set for the language. Fundamental note: your program is not expected to verify that file argument_file complies with the above specifications. It will only be tested with compliant files. The following example should be regarded as the reference specification for the format of file argument_file: German de ISO-8859-1 English en ISO-8859-1 Chinese zh GB2312 4. English en ISO-885 Chinese zh GB2312 Italian it ISO-8859-1 Japanese ja EUC-JP Korean Hindi ko hi UTF-8 Vietnamese vi UTF-8 EUC-KR Your program can be invoked with option: -a. In this case, it must print all the language names in file argument_file in alphabetical order, in this format: Languages in this file: first 3 name in alphabetical order 4. Vietnamese vi UTF-8 Your program can be invoked with option: -a. In this case, it must print all the language names in file argument_file in alphabetical order, in this format: Languages in this file: first name in alphabetical order second name in alphabetical order last name in alphabetical order Example with file argument_file given above: Command line: python languages.py -a argument file Expected output: Languages in this file: Chinese English German Hindi Italian Janan 5. Korean Vietnamese In the case in which file argument_file is empty, your program must instead only print: No languages in this file Your program can be invoked with option: -c code. The code argument has the same format as the code field in the argument file. In this case, your program must search for the code in the argument file, and if it finds it, print the language name. This is an example with file argument_file given above: Command line: python languages.py -c it argument_file Expected output: Italian In the case in which your program cannot find the given code in the argument file (including the case where the argument file is empty), it must print: 6. Code code not present in this file Example with file argument_file given above: Command line: python languages.py -c fr argument_file Expected output: Code fr not present in this file Your program can be invoked with option: -s set. The set argument has the same format as the set field in the argument file. In this case, your program must search for all the matches between the set argument and the set field in the argument file, and print all the corresponding language names, in the order in which they appear in the file. This is an example with file argument_file given above: Command line: python languages.py s ISO-8859-1 argument_file Expected output: 7. 8. English Italian In the case in which your program cannot find the given set in the argument file (including the case where the argument file is empty), it must print: Character set set not present in this file Example with file argument_file given above: Command line: python languages.py -s ISO-8859-7 argument_file Expected output: Character set ISO-8859-7 not present in this file Your program can be invoked with option: -v. In this case, it must only print your name, surname, student ID and date of completion of your assignment, in a format of your choice. Please note that argument argument file is still required. No options can be used simultaneously. This means that your program can only be invoked with one of the options at a time. L3
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
What important retailing decisions to the target market and retailing marketing mix should be considered when investing in: Dunkin Donuts Little Caesars Pizza Starbucks
-
1. Which country has an absolute advantage in wine? 2. Which country has an absolute advantage in coffee? 3. What is the opportunity cost of wine in each country? 4. What is the opportunity costs of...
-
Explain the notions of transparency and autonomy. Why are these notions desirable from a human-factors stand point?
-
If Indian Telecom Company earned INR 350,000 (Indian rupee) in net income, and paid cash dividends of INR 70,000, what are Indian Telecoms earnings per share if it has 100,000 shares outstanding?
-
1. Identify the ethical culture problem at Texaco in the mid-1990s. 2. Based on the facts in the case and what you have learned in this chapter, evaluate the culture change effort that is under way....
-
1. Find the focal length of a convex mirror of radius of curvature 1m. 2. Focal length of a convex mirror is 50 cm. What is its radius of curvature? 3. Radius of curvature of a concave mirror is 25...
-
Kool Air (Pty) Limited, a manufacturer of industrial fans, has a taxable income of R2 400 000 for its financial year ended 28 February 2021, before taking the following into consideration: In...
-
Which cash flow has the greatest present value if your discount rate is 9.5%? A) A lump sum payment of $10,000 today B) A lump sum payment of $25,000 at the end of 10 years C) A perpetual stream of...
-
A design change being considered by Mayberry, Inc., will cost \(\$ 6,000\) and will result in an annual savings of \(\$ 1,000\) per year for the 6-year life of the project. A cost of \(\$ 2,000\)...
-
Nadine Chelesvig has patented her invention. She is offering a potential manufacturer two contracts for the exclusive right to manufacture and market her product. Plan A calls for an immediate single...
-
Several years ago, a man won \(\$ 27\) million in the state lottery. To pay off the winner, the state planned to make an initial \\($1\) million payment immediately followed by equal annual payments...
-
Assume that S&P 500 at close of trading yesterday was 3,040 and the daily volatility of the index was estimated as 1% per day at that time. The parameters in a GARCH(1,1) model are v = 0.000002, a =...
-
A fund manager has a well-diversified portfolio that mirrors the performance of an index and is worth $360 million. The value of the index is 1,200, and the portfolio manager would like to buy...
-
Warm Hands sells its motorcycle gloves worldwide. Warm Hands expects to sell 2,600 pairs of gloves for $110 each in January and 2,000 pairs of gloves for $130 each in February. All sales are cash...
-
Walker, Inc., is an all-equity firm. The cost of the company's equity is currently 11.4 percent and the risk-free.rate is 3.3 percent. The company is currently considering a project that will cost...
-
This operator determines whether one string is contained inside another string. a. Contains b. Is_in c. == d. In
-
What command would you use to set the size of the turtles graphics window to 500 pixels wide by 200 pixels high?
-
True or False Machine language is the only language that a CPU understands.
-
An investor is considering adding three new securities to her internationally focused, fixed-income portfolio. She considers the following non-callable securities: 1-year government bond 10-year...
-
An Australian investor currently holds an A$240 million equity portfolio. He is considering rebalancing the portfolio based on an assessment of the risk and return prospects facing the Australian...
-
An analyst is reviewing various asset alternatives and is presented with the following information relating to the broad equity market of Switzerland and various industries within the Swiss market...
Study smarter with the SolutionInn App