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 loop that counts the number of space

Write a loop that counts the number of space characters in a string. Recall that the space character is represented a

  Improve the code for the haunted house game

Improve the readability of the code by improving the function names, variables, and loops, as well as whitespace. Document these changes in your journal and define a win condition for the game, for example, collecting all items and returning to the..

  Implement your algorithm in python

Write a Python program that, for every transaction, takes input on the customer ID and the total sale amount in the transaction.

  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.

  The program should use a boolean= valued function

Write a program that accepts a word as input and determines wehther or not it has three consecutive letters in the alphabet. The program should use a Boolean= valued function named isTripleConsecutive that accepts an entire word as input.

  Let ll be a list of integers

Let LL be a list of integers. Use list comprehension to produce teh following lists. Each one should just take onel line. Anser questions as two comments.

  Design an application in python

Design an application in Python- The application would generate a set of 100 integers in a random manner in the range of 50 to 150 including both the numbers in the range

  How many cents for each paper

Using Tkinter for cents Program, find the How many cents for each Paper

  What prompted the authors to try and address

What is the question that this study is trying to answer and what prompted the authors to try and address this question?

  Write a function rmduplic(l), where l is any list

Write a function rmDuplic(L), where L is any list. The function should return a list M that contains the same items as L, except that repetitions (duplicates) have been removed: only the first occurrence of each entry is kept (i.e., order is prese..

  Create a cheat commands in the game

Create a cheat commands in the game so player can pick up any item he wants from any location in the map - Display all possible actions you can carry out in game.

  Assignment work in python

Write a function interleave two pictures take the first 20 pixels from the first picture and then 20 pixels from the second picture and then the next 20 pixels from the first picture and then the next 20 pixels from the second picture and so on till ..

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