Revise function compare_files to accomplish the work describ

Assignment Help Python Programming
Reference no: EM131099666

Lab Exercise

Assignment Overview

This lab exercise provides practice with sets in Python.

You will work with a partner on this exercise during your lab session. Two people should work at one computer. Occasionally switch the person who is typing. Talk to each other about what you are doing and why so that both of you understand each step.

Part A: Programming with Sets

Consider the file named "lab11a.py". That file contains the skeleton of a Python program to do a simple analysis of two files: it will display the number of unique words which appear in the two files (the union of those two sets of words), as well as the number of unique words which are common to both files (the intersection of those two sets of words).

Case does not matter: the words "pumpkin", "Pumpkin" and "PUMPKIN" should be treated as the same word. Only unique words should be counted: if a word appears more than once in a file, it should only be counted once. Note: remember to remove punctuation from words, e.g. "it," should be "it"

a. Replace the comments labeled "YOUR COMMENT" in function "build_word_set" with meaningful comments to describe the work being done in the next statement. Use more than one comment line, if necessary.

b. Revise function "compare_files" to accomplish the work described in the comments.

c. Test the revised program. There are two sample documents available: "document1.txt" (The Declaration of Independence) and "document2.txt" (The Gettysburg Address).

« Demonstrate your completed program to your TA. On-line students should submit the completed program (named "lab11a.py") for grading via the CSE handin system.

Part B: Programming with Dictionaries and Sets

Consider the file named "lab11b.py". That file contains the skeleton of a Python program to display information about the words in a document.

Function "main" is complete. It handles the interaction with the user and calls other functions to perform the appropriate tasks.

Function "print_word_index" is complete. It receives a dictionary, where each element is a word and a set of line numbers where that word appears in a document. It displays all of the words (in alphabetic order), along with the lines numbers for each word (in ascending order).

Function "build_word_index" is incomplete. It receives an input file and builds a dictionary containing the unique words which appear in the input file, along with the line numbers where each word appears. The first line of the input file should be considered to be line 1.

a. Revise function "build_word_index" to accomplish the specified work. You may wish to review function "build_word_set" (above) for ideas about how to handle upper and lower case letters, as well as punctuation.

b. Test the revised program using the sample documents.

« Demonstrate your completed program to your TA. On-line students should submit the completed program (named "lab11b.py") for grading via the CSE handin system.

Attachment:- Lab Exercise.zip

Reference no: EM131099666

Questions Cloud

A major producer of farm equipment : Oswego Corporation is a major producer of farm equipment. Oswego stock currently sells for $36 per share; there are 25 million shares outstanding. Oswego also has perpetual debt outstanding with an aggregate market value of $600 million and a yiel..
The cash flow to debt and the cash flow : Suppose a firm has outstanding debt securities of $100 million with an obligatory payment of $8 million per year. What is the cash flow to debt and the cash flow to equity if the firmcash flow level is: a. $40 million b. $20 million c. $10 million..
Analysis of the leadership theory : Write a 500-word analysis of the leadership theory you believe is most appropriate for project managers and provide the rational for your choice
Describe in detail the business case for a company : Describe in detail the business case for a company to undertake the strategic changes identified previously, which will be required for the business to survive in the climate resulting from the "disruption.'
Revise function compare_files to accomplish the work describ : Revise function "build_word_index" to accomplish the specified work. Revise function "compare_files" to accomplish the work described in the comments. Test the revised program using the sample documents.
Determine the proportion of american : A study was conducted to determine the proportion of American teenagers between 13 and 17 who smoke. Previous surveys showed that 15% percent of all teenagers smoke. A Gallup survey interviewed a nationally representative sample of 785 teenagers a..
Working for a lawyer estimates the annual earnings : For purposes of compensation, an actuary working for a lawyer estimates the annual earnings of a September 11 victim that died at the Twin Towers at age 32. The victim was making $95,000 a year and a stream of payments for that amount would have l..
Probability that the mean of the sample : Assuming the manufacturer's claim is correct, what is the probability that the mean of the sample is 47,860 miles or less?
Determine the poles of the circuit : Due to manufacturing error, a parasitic resistor Rp has appeared in the cascode stage of Fig. 11.90. Assuming λ = 0 and using Miller's theorem, determine the poles of the circuit.

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