Questions
Instructions In this exercise, you will use Python to complete four practical challenges: Creating 24 directories...

Instructions

In this exercise, you will use Python to complete four practical challenges:

  • Creating 24 directories for each week of class, each containing 3 folders for each day of class
  • Copying files from ~/Downloads into the current directory
  • Adding the copy script to the PATH
  • Add an alias for the copy script to ~/.bashrc

Class Notes Folder

Create a script called create_notes_drs.py. In the file, define and call a function called main that does the following:

  • Creates a directory called CyberSecurity-Notes in the current working directory
  • Within the CyberSecurity-Notes directory, creates 24 sub-directories (sub-folders), called Week 1, Week 2, Week 3, and so on until up through Week 24
  • Within each week directory, create 3 sub-directories, called Day 1, Day 2, and Day 3

Bonus Challenge: Add a conditional statement to abort the script if the directory CyberSecurity-Notes already exists.

Copying Student Exercises

So far you've used a few different Python modules, but for the rest of the homework, you will need to familiarize yourself with a new one. The shutil module is a Python module used for high-level file operations like moving and copying. Read this beforehand to get familiar with shutil and make sure to use the documentation while you're working through the homework.

Create a script called copy_activities.py with a function called stu_activities that does the following:

  • Finds files in ~/Downloads that contain the string Stu_
  • Copies these files into the current working directory

Note: This isn't just a challenge to complete for the sake of it, this is a practical script you can run to move any downloaded files from class into your class notes directories.

Copy Class Slides

Create a script called copy_slides.py with a function called pptx_copy Students will create a script that does the following:

  • Finds files in ~/Downloads with the file extension .pptx or .ppt
  • Copies these files into the current working directory

Note: This is another practical script you can use to move downloaded slides from class into your class notes directories.

Updating PATH and Add an Alias

Note: Consider this a bonus. You do not need to complete this step for credit. But, these tools will come up in class later, so you're strongly encouraged to study up now!

Now these great scripts have been written, but they are only executable from their relative path - where the files are in your system. In this final step, we'll make them accessible to you anywhere in your system directory.

  • First, read the following article to learn more about .bashrc, PATH, aliases, and the export command and answer the following questions.
    • What is the main difference betweeen ~/.bashrc and the ~/.bash_profile?
    • What does the export PATH command do?
    • What is the benefit of creating aliases?
  • Create a directory called /usr/local/bin and move your three scripts into this directory.
  • Update your .bashrc to add the directory /usr/local/bin to PATH with the following command:
export PATH=$PATH:/usr/local/bin
  • Finally create aliases in .bashrc for the three scripts
    • alias copy_activities="copy_activities.py"
    • alias copy_slides="copy_slides.py"
    • alias create_notes_drs="create_notes_drs.py"

In: Computer Science

Python is a great tool for automating a number of tasks, including scanning and summarizing the...

Python is a great tool for automating a number of tasks, including scanning and summarizing the files in a file system.

Write a Python class, FileAnalyzer that given a directory name, searches that directory for Python files (i.e. files ending with .py). For each .py file, open each file and calculate a summary of the file including:

  • the file name
  • the total number of lines in the file
  • the total number of characters in the file
  • the number of Python functions (lines that begin with ‘def ’, including methods inside class definitions)
  • the number of Python classes (lines that begin with ‘class ’)

Generate a summary report with the directory name, followed by a tabular output that looks similar to the following:

The class FileAnalyzer should have at least these attributes and these methods listed below:

  • Attributes:
    • self.files_summary: dict, a Python dictionary that store the summarized data for the given file path. The keys of dictionary will be the filename of a python file, the value of each key will be a dict as well. The value dictionary will have 4 key-value pairs that represent 4 data points we collect for each file. The structure of self.files_summarywill look like below:
{
    'filename_0.py': {
        'class': # number of classes in the file
        'function': # number of functions in the file
        'line': # number of lines in the file
        'char': # number of characters in the file
    }, ...
}
  • Methods:
    • self.analyze_files(self): a method that populate the summarized data into self.files_summary. Note that you MUST NOT pass any argument to this method, the given directory path is better stored as an attribute - there will be no naming requirement for this variable but I personally use self.directory.
    • self.pretty_print(self): a method that print out the pretty table from the data stored in the self.files_summary. Note that you MUST NOT pass any argument, other than self, to this method.

Note: Your should execute the self.analyze_files in the self.__init__ but you MUST NOTexecute the self.pretty_print in the self.__init__, you will get 10 points deducted if you do so.

Keep in mind that you may see a file, but you may not be able to read it. In that case, raise a FileNotFound exception if the specified file can’t be opened for reading

Your program should use exceptions to protect the program against unexpected events.

The PrettyTable module (Links to an external site.) provides an easy way to create tables for output. You should use PrettyTable to format your table. See the lecture notes for an example.

You’ll need to think about how to test this program with unittest. You do not need to automatically verify the output from the table but you should validate the various numeric values, e.g. number of classes, functions, lines, and characters. Your automated test should validate the counts for each file in the test directory.

Hints:

  1. Python’s os module has several helpful functions, e.g. os.listdir(directory) lists all of the files in the specified directory. Note that the file names returned by os.listdir do NOTinclude the directory name.
  2. os.chdir(directory) will change the current directory to the specified directory when your program runs.
  3. Be sure to handle the cases where the user enters an invalid directory name
  4. Test your code against the sample files in Canvas
  5. Be sure to use unittest to test your program and follow the PEP-8 coding standards.

In: Computer Science

For 80x86 assembly language and computer architrctureIn terms of modules, define an export.Which entry...

For 80x86 assembly language and computer architrcture

In terms of modules, define an export.

Which entry of the resource directory identifies the start of the export directory?

What is the role of the import table in dynamic linking?

What is the primary benefit of storing a precomputed import address into IMAGE_IMPORT_DESCRIPTOR.FirstThunk?

In: Computer Science

Use the information below to answer the following question(s): Cruise Company produces a part that is...

Use the information below to answer the following question(s):
Cruise Company produces a part that is used in the manufacture of one of its products. The unit manufacturing costs of this part, assuming a production level of 6,000 units, are as follows:
Direct materials $4.00
Direct labour $4.00
Variable manufacturing overhead $3.00
Fixed manufacturing overhead $1.00
Total cost $12.00
The fixed overhead costs are unavoidable.
6. Assuming Cruise Company can purchase 6,000 units of the part from Suri Company for $9 each, and the facilities currently used to make the part could be rented out to another manufacturer for $24,000 a year, what should Cruise Company do?
a. Make the part and save $6.00 per unit.
b. Make the part and save $2.00 per unit.
c. Buy the part and save $2.00 per unit.
d. Buy the part and save $6.00 per unit.

7. Assume Cruise Company can purchase 6,000 units of the part from Suri Company for $14.00 each, and the facilities currently used to make the part could be used to manufacture 6,000 units of another product that would have an $8 per unit contribution margin. If no additional fixed costs would be incurred, what should Cruise Company do?
a. Make the new product and buy the part to earn an extra $5.00 per unit contribution to profit.
b. Make the new product and buy the part to earn an extra $6.00 per unit contribution to profit.
c. Continue to make the part to earn an extra $2.00 per unit contribution to profit.
d. Continue to make the part to earn an extra $4.00 per unit contribution to profit.

In: Accounting

Promoting the Financial Planning Cruise to Better Horizons Credit Union Members Write a sales message to...

Promoting the Financial Planning Cruise to Better Horizons Credit Union Members

Write a sales message to Better Horizons members to promote the financial planning cruise. Feel free to add additional details (i.e., price and dates for the cruise).

Must be Persuasive!!!

Scenario: Christine Russo works at Better Horizons and is developing several new services the credit union could offer. One idea is for credit union members to take a five-day cruise to the Bahamas. Two afternoons of the cruise will be devoted to financial planning workshops, including choices such as retirement planning, trusts and estates, insurance, charitable giving, taxes, and college savings. Also, a finance boot camp for teenagers will provide basic information about savings and checking accounts, loans, and budgeting.

In another initiative, Christine wants to set up a new rewards program for credit union members who use their Better Horizons debit or credit cards. Each purchase with the debit or credit card will contribute to their total reward points, which customers can redeem for brand-name merchandise, hotel accommodations, airline tickets, cruises, and other travel options (detailed in an online and paper merchandise and travel catalog). Members get one point for each dollar spent on their credit cards and one point for every two dollars spent on their debit cards. One advantage of the program is that points can be combined across accounts. So, family members Page 331or friends who are members of the credit union can transfer their points to one another’s accounts and more quickly gain rewards. The program involves no fee, and members with the cards are automatically enrolled in the program.

In: Finance

Which of the following statements are true and which are false. In general, at a given...

Which of the following statements are true and which are false.

In general, at a given temperature, the reaction quotient (Q) is a constant.


1 mol of H2O(g) and 1 mol of CO(g) are placed in a vessel and 1 mol of H2(g) and 1 mol of CO2(g) are placed in another of equal volume. At equilibrium, at 350°C, the amounts of H2O(g) in the two vessels are equivalent.


Amounts of all reactants and products corresponding to an exact equilibrium composition for this reaction are sealed in a vessel. The CO placed in the vessel is labelled with 14C. After an indefinite period of time 14C would still be found only in the CO molecules and not in CO2.


At equilibrium, individual molecules cannot undergo any chemical reactions.


At equilibrium, the overall composition of the reaction mixture is changing rapidly.


The equilibrium constant does not reveal the rate of that reaction.

In: Chemistry

You are asked to write a legal memorandum which follows the IRAC method. In this method...

You are asked to write a legal memorandum which follows the IRAC method. In this method you are expected to identify the ISSUE presented to you, identify the RULE(s) that are applicable, APPLY the rule(s) to the case and provide your CONCLUSION.

Semester Assignment #1

Tim and Lisa Parker have come to your law office and relate the following facts: While Tim and Lisa were still married, Lisa purchased insurance on their home from American Security Insurance Company. The policy was issued on November 3, 2010, listing the “insured” as Lisa L. Parker. Shortly thereafter the Parkers entered into a separation agreement under which Lisa deeded her interest in the house to Tim. The Parkers were divorced on August 26, 2015. On November 28, 2016, the house was destroyed by fire. American Security refused to pay on the policy, claiming that Lisa had no insurable interest in the property at the time of the loss. The Parkers sued the insurer, contending that they were entitled to payment under the policy issued to Lisa.

Their misfortune with insurance companies did not end there, after additional discussion they also related:

They also owned rental property in Lake Charles, Louisiana, that was damaged by a tree falling into the building, shearing off a portion of the facade during Hurricane Sam in September 2014. By October 7, 2014, they notified their insurer, Lafayette Insurance Co., of the damages to this property. In September 2016, two years after the hurricane, the Parkers filed a lawsuit against the issuer for breach of the insurer’s duty of good faith and fair dealing in adjusting losses associated with the hurricane. The jury found in favor of the Parkers, concluding that the plaintiffs sustained losses in excess of the amount paid under the defendant’s policy in the amount of $144,800.00. Further, the jury concluded that the defendant: (1) failed to initiate a loss adjustment to the property within 30 days after notification of loss; (2) was arbitrary, capricious, or without probable cause in failing to pay any claim due within 60 days after receipt of satisfactory proof of loss; (3) failed to make an offer to settle the property damage within 30 days of receipt of satisfactory proof of loss; and (4) misrepresented pertinent facts or insurance policy provisions related to coverage at issue. From a judgment for the Parkers, Lafayette appealed.

After the meeting the Parker’s decide to retain your law firm to deal with these two issue. As a firm paralegal you have been assigned to the case to assist the assigned attorney who happens to be the senior partner of the firm. The senior partner would like you to provide a legal memorandum. In the memorandum you are required to identify the issues, the rules, how those rules will likely be applied and your conclusion about how any legal action will play out. Remember you must base all of your positions on the law or facts and must cite accordingly.

Assignment #2

Thomas Crowne is in your law office asking for legal help. He states he had over $300,000 in student loans that were used to finance his education at Mercer University where he obtained an A.B., an M.B.A, and another unspecified graduate degree as well as a large number of courses toward his J.D. degree. He did not make payments on these student loans. In 1996, he was elected assessor for Putnam County, Tennessee, a position he held for two years and four months. He was then convicted of the first-degree murder of state senator Tommy Burks. He exhausted all of his appeals and is currently serving a life sentence without the possibility of parole. The debtor has one dependent, a son born in August 1998. The circuit court for Putnam County, Tennessee, ordered Crowne to pay child support of $161.00 per month plus $7,254.20 in medical expenses. Crowne did not make any of the court-ordered child support payments and was in arrears by more than $23,515.00. Crowne asked to have his student loans discharged on the basis of his hardship.

You have been assigned as the paralegal to assist in this case. Ron Reacher is the attorney assigned and has asked you to research the facts of the case and provide a memorandum outlining the applicable issues, the applicable rules, how the rules apply to the facts and an opinion of the outcome of the case. He has also asked that you make sure to include:

How Bankruptcy Is Declared, Administration of the Bankruptcy Estate, Debtor’s Duties and Exemptions, Discharge in Bankruptcy, Reorganization Plans under Chapter 11, and Payment Plans under Chapter 13.

Remember you must base all of your positions on the law or facts and must cite accordingly.

Assignment #3

Norman Fell is in your law office and relates the following information: He attended an auction at B & B Antiques, Auction & Realty, a business owned and operated by Ray Thompson, Deborah Thompson, Bo Thompson, and Laura Thompson (collectively 'the Thompsons'). Fell purchased five lamps that were identified at the auction as “Tiffany” lamps and one lamp shade that was also identified at the auction as a “Tiffany” product. Fell spent a total of $56,200 on the lamps.

Fell contacted Fontaine's Auction Gallery in Pittsfield, Massachusetts, to inquire about selling the lamps in an auction. Fontaine's sent Dean Lowry, an expert in Tiffany products, to examine Fell's lamps and Lowry determined that the lamps were not authentic Tiffany products but were, in fact, reproductions. Fell filed suit against the Thompsons and B & B for fraudulent suppression, fraudulent misrepresentation, and breach of warranty, breach of contract, negligence, and wantonness. B & B was dismissed from the case because it had not yet been properly formed as an LLC. The Thompsons claimed they thought the lamps were authentic and that their auction brochure contained the following:

Conditions of Sale:

1. All property is sold AS IS WHERE IS, and we make NO guarantees, warranties or representations, expressed or implied, with respect to the property or the correctness of the catalog or other description of authenticity of authorship, physical condition, size, quality, rarity, importance, provenance, exhibitions, literature or historical relevance of the property or otherwise. No statement anywhere, whether oral or written, shall be deemed such a guarantee, warranty or representation.

On a motion for summary judgment, the court found for the Thompsons, indicating that Fell trusted blindly and should not have done so. Fell asks you to help him appeal the decision.

You have been assigned to the case along with attorney Miranda Suarez. She has asked you to research the case and provide a memorandum. In the memorandum you are required to identify the issues, the rules, how those rules will likely be applied and your conclusion about how any legal action will play out. Remember you must base all of your positions on the law or facts and must cite accordingly.

In: Operations Management

What are the UNIX codes for each of these steps Display the directories and sub-directories including...

What are the UNIX codes for each of these steps

  1. Display the directories and sub-directories including files so I can verify your starting point.
  2. Redirect the above step to the lab3.txt file
  3. Make a sub-directory named Files in your user directory

In: Computer Science

Answer this question in light of the concepts, cultural types, value orientations and analytical frameworks provided...

Answer this question in light of the concepts, cultural types, value orientations and analytical frameworks provided on the course and applied during the seminars.
A​A South-American telecoms company wanted to find a partner to handle its telecoms system. Two firms, one American and one European, were in final contention. The Europeans visited the country for three weeks, getting to know the people in the exchanges, understanding how the operation works and the workforce’s problems. The American team spent three days in the capital, meeting and presenting to the top brass. They offered a better specification system than the Europeans and at a lower price. But the European firm won the contract!!
B​After extremely long negotiations, the US delegation was pleased to see that the contract for a new venture project with their Chinese partners was ready to be signed. They were particularly impressed that the Chinese had invited local dignitaries to the signing ceremony. Everything went smoothly until work on the new factory was supposed to begin. It was found that the Chinese were not following the conditions laid down in the contract, and had even suggested further negotiations.

In: Finance

I am attempting to write a script using bash on Linux. My program must save the...

I am attempting to write a script using bash on Linux. My program must save the long list format of the parent directory to a text file. Then, it must print how many items are in this parent directory. Then, it must sort the file in reverse order and save it to a different text file.

I understand that the parent directory is accessed using cd .., and I understand that a file can be written to by echoing and using >> fileName, and that |wc -l can be used to count the lines, but I am otherwise lost.

Any help would be greatly appreciated, thank you.

In: Computer Science