logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

Write a program that takes in a filename and string as input.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Exercises

If you manually close the file by calling .close(), the file may not be closed in exceptional circumstances. Always use the with statement when opening files in Python. See prelab9 for more detail.

Exercise 2.1 (word_count.py).

Write a program that takes in a filename and string as input. Then print how many times that string appears inside the chosen file. If the file does not exist, continue asking for a filename until one is given that exists. Use your source code file as test input.

Make sure to test files with that contain the same word multiple times.

Exercise 2.2 (design, simplediff.py).

Before attempting to code this problem, create a file design that contains some analysis of how you think the problem will be solved. Examples include but are not limited to: a flowchart of events in the program, pseudocode, or a step-by-step process written in plain English. If you choose to scan your design, please make sure that it is legible.

Write a “diff” program that prints out the differences, line by line, of two files. Your program should ask the user for the names of two files, then print the differences between them. Follow the format output as shown below. Make sure to use proper error handling techniques for file I/O.

Assume all files have the same number of lines. The following output shows the output of the files file1.txt and file2.txt.

Exercise 2.3 (readscores.py).

Download the file actsat.txt provided on Canvas. It contains the following columns of whitespace-separated data:

 

Column 1 2-letter state/territory code (includes DC) Column 2 % of graduates in that state taking the ACT Column 3 Average composite ACT score

Column 4 % of graduates in that state taking the SAT Column 5 Average SAT Math score

Column 6 Average SAT Reading score Column 7 Average SAT Writing score

You must open this file and generate a list of dictionaries containing each row of data. Please use these keys for the dictionaries:

 

 

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

823 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

547 Answers

Hire Me
expert
Husnain SaeedComputer science

849 Answers

Hire Me
expert
Atharva PatilComputer science

849 Answers

Hire Me

Get Free Quote!

415 Experts Online