Question

Using the string below to make a list of words, show that there are 272 words...

Using the string below to make a list of words, show that there are 272 words in the Gettysburg Address.

How many distinct words are in the speech?

Hint: You may need to delete some of the punctuation, including new lines, which are represented by \n.

In [63]:

gettysburg_address = """Four score and seven years ago our fathers brought forth on this 
continent, a new nation, conceived in Liberty, and dedicated to the proposition that all 
men are created equal.
Now we are engaged in a great civil war, testing whether that nation, or any nation so 
conceived and so dedicated, can long endure. We are met on a great battle-field of that war. 
We have come to dedicate a portion of that field, as a final resting place for those who here
gave their lives that that nation might live. It is altogether fitting and proper that we 
should do this.
But, in a larger sense, we can not dedicate-we can not consecrate-we can not hallow-this 
ground. The brave men, living and dead, who struggled here, have consecrated it, far above
our poor power to add or detract. The world will little note, nor long remember what we say
here, but it can never forget what they did here. It is for us the living, rather, to be 
dedicated here to the unfinished work which they who fought here have thus far so nobly 
advanced. It is rather for us to be here dedicated to the great task remaining before 
us-that from these honored dead we take increased devotion to that cause for which they 
gave the last full measure of devotion-that we here highly resolve that these dead shall 
not have died in vain-that this nation, under God, shall have a new birth of freedom-and 
that government of the people, by the people, for the people, shall not 
perish from the earth."""

In [64]:

# Use string operations to fill in the right-hand side and make a word list.
#word_list = ????

# Use this line to remove the blank word from the list
word_list = [word for word in word_list if word is not '']

Homework Answers

Answer #1

If you have any doubts, please give me comment...

import string

gettysburg_address = """Four score and seven years ago our fathers brought forth on this

continent, a new nation, conceived in Liberty, and dedicated to the proposition that all

men are created equal.

Now we are engaged in a great civil war, testing whether that nation, or any nation so

conceived and so dedicated, can long endure. We are met on a great battle-field of that war.

We have come to dedicate a portion of that field, as a final resting place for those who here

gave their lives that that nation might live. It is altogether fitting and proper that we

should do this.

But, in a larger sense, we can not dedicate-we can not consecrate-we can not hallow-this

ground. The brave men, living and dead, who struggled here, have consecrated it, far above

our poor power to add or detract. The world will little note, nor long remember what we say

here, but it can never forget what they did here. It is for us the living, rather, to be

dedicated here to the unfinished work which they who fought here have thus far so nobly

advanced. It is rather for us to be here dedicated to the great task remaining before

us-that from these honored dead we take increased devotion to that cause for which they

gave the last full measure of devotion-that we here highly resolve that these dead shall

not have died in vain-that this nation, under God, shall have a new birth of freedom-and

that government of the people, by the people, for the people, shall not

perish from the earth."""

# In [64]:

# Use string operations to fill in the right-hand side and make a word list.

word_list = [word for word in gettysburg_address.replace("-", " ").replace("\n", " ").split(" ")]

# Use this line to remove the blank word from the list

word_list = [word for word in word_list if word is not '']

print("Total words:", len(word_list))

print("Unique wors:", len(set(word_list)))

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Please write a python code for the following. Use dictionaries and list comprehensions to implement the...
Please write a python code for the following. Use dictionaries and list comprehensions to implement the functions defined below. You are expected to re-use these functions in implementing other functions in the file. Include a triple-quoted string at the bottom displaying your output. Here is the starter outline for the homework: d. def count_words(text): """ Count the number of words in text """ return 0 e. def words_per_sentence(text): return 0.0 f. def word_count(text, punctuation=".,?;"): """ Return a dictionary of word:count...
You've been hired by Text Turtles to write a C++ console application that determines the reading...
You've been hired by Text Turtles to write a C++ console application that determines the reading grade level of the text in a file. The text comes from two files: SampleText1.txt and SampleText2.txt. Sample text1= It has often been said there's so much to be read you never can cram all those words in your head. So the writer who breeds more words than he needs is making a chore for the reader who reads. That's why my belief is...
Write a program in python that reads in the file quiztext (txt) and creates a list...
Write a program in python that reads in the file quiztext (txt) and creates a list of each unique word used in the file, then prints the list. Generate a report that lists each individual word followed by the number of times it appears in the text, for example: Frequency_list = [('was', 3), ('bird',5), ('it', 27)….] and so on. Note: Notice the structure: a list of tuples. If you're really feeling daring, Google how to sort this new list based...
Develop a C++ PROGRAM which will find a hidden sentence in a list of random words...
Develop a C++ PROGRAM which will find a hidden sentence in a list of random words using map function Open this text file named shuffled_words.txt in your program If it matters, you may presume there are an even number of words in the file Place the contents of the file into an appropriate data structure in the following manner: Grab a pair of strings from the file (unless end of file is reached) Each string is separated by a space...
Write a Python 3 program called “parse.py” using the template for a Python program that we...
Write a Python 3 program called “parse.py” using the template for a Python program that we covered in this module. Note: Use this mod7.txt input file. Name your output file “output.txt”. Build your program using a main function and at least one other function. Give your input and output file names as command line arguments. Your program will read the input file, and will output the following information to the output file as well as printing it to the screen:...
Here are the choices for each of the 15 configuration options in the 2 words that...
Here are the choices for each of the 15 configuration options in the 2 words that we have used: __CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOREN_OFF & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF __CONFIG _CONFIG2, _WRT_OFF & _PLLEN_OFF & _STVREN_ON & _BORV_LO & _LVP_OFF List how many bits for each option and explain why we chose each option or if it makes no difference. 3. How many bits in each configuration word? 4....
Give 3-5 examples of how FDR mentioned land labor and capital public works as part of...
Give 3-5 examples of how FDR mentioned land labor and capital public works as part of the engine of economic recovery. HERE IS THE PASSAGE: “I am certain my fellow Americans......This great Nation will endure as it has endured, will revive and will prosper. So, first of all, let me assert my firm belief that the only thing we have to fear is fear itself—nameless, unreasoning, unjustified terror which paralyzes needed efforts to convert retreat into advance. In every dark...
Reply to the discussion post 1 and 2 in your own words: Post 1: The best...
Reply to the discussion post 1 and 2 in your own words: Post 1: The best positive historical example would be the nationwide assistance of the government to avoid another depression or a full on recession. The Great Depression previously did the opposite steps of what the government would do today. Instead of taking money, they gave money back to the people. Doing so, kept money in the economy and people felt comfortable spending and keeping it going. In the...
make a detail responce to the following paragragh: Growing old is different for all catagories of...
make a detail responce to the following paragragh: Growing old is different for all catagories of people for many reasons. In some cultures being old is a good thing showing that you have wisdom for being around more while other societies want to stay young and live the younger person lifestyle. Like the book said early in the chapter we are seeing a rise in the average age which means that there are more old people around today than back...
Provide a substantive response (50-150 words minimum) to the posting below. Be clear about what aspect...
Provide a substantive response (50-150 words minimum) to the posting below. Be clear about what aspect of your classmate's post you are responding to. One option is to start by quoting a portion of your classmate's post to show specifically what part of your classmate's post you are responding to (but this does not count toward the total minimum word count expected). "To make schools less bureaucratic we would need to eliminate the characteristics of bureaucracy that Max Weber noted...