Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IsUSCurrentPresidentCatholic = True IsUSPreviousPresidentCatholic = False Change the values of the two variables above to print all the statements of the code.below if (IsUSCurrentPresidentCatholic) or

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
IsUSCurrentPresidentCatholic = True IsUSPreviousPresidentCatholic = False Change the values of the two variables above to print all the statements of the code.below if (IsUSCurrentPresidentCatholic) or (IsUSPreviousPresidentCatholic): print('The current USA president is catholic or the previous USA president is catholic') if (IsUSCurrentPresidentCatholic) and not(IsUSPreviousPresidentCatholic): print('The current USA president is catholic but the previous USA president is not catholic') elif not(IsUSCurrentPresidentCatholic) and (IsUSPreviousPresidentCatholic): print('The current USA president is not catholic but the previous USA president is catholic') else: print('The current USA president and the previous USA president are both catholic') else: print('The current USA president and the previous USA president are not catholic') Using the for loop: - List all the presidents whose names contain the letter ' a ' - List all the presidents whose names do not contain the letter ' m ' - For each president, list the number of times the letter 'a' appears listUSPresidents=["George Washington","John Adams","Thomas Jefferson","James Madison","James Monroe ", "John Quincy Adams","Andrew Jackson","Martin Van Buren", "Willam H. Harrison", "John Tyler","James K. Polk", "Zachary Taylor","Millard Fillmore","Franklin Pierce","James Buchanan","Abraham Lincoln","Andrew Johnson","Ulysses S. Grant","Rutherford B. Hayes","James A. Garfield", "Chester A. Arthur","Grover Cleveland","Benjamin Harrison", "Grover Cleveland","Williahn McKinley", "Theodore Roosevelt", William H. Taft," Woodrow Wilson", "Warren G. Harding","Calvin Coolidge","Herbert Hoover","Franklin D. Roosevelt","Harry S. Truman","Dwight D. Eisenhower", "John F. Kennedy","Lyndon B. Johnson","Richard M. Nixon","Gerald R. Ford","Jimmy Carter","Ronald Reagan", "George H. W. Bush","Bill Clinton", "George W. Bush", Barack Hussein Obama","Donald J. Trump"] NLTK includes a small selection of texts from the Project Gutenberg electronic text archive, which contains some 25,000 free electronic books, hosted at http:/Www.gutenberg.org/. See https://www.nltk.org/book/ch02.html for more information The code below loads the file identifiers in this corpus import nitk nltk download("book") print(nitk.corpus gutenberg.raw('austen-emma.txt')) emma = nitk corpus gutenberg. raw('austen-emmatxt'), replace("Vninin;" "), replace("Din; ; ") replace("7n"; ") emma We will focus on the novel Emma by Jane Austen Create a dictionary of words with their frequency. The key in the dictionary is the word, and the frequency is the value. Please, follow the steps below, to complete the assignment: - create the list of the words in the Emma novel. Think of using the split method of string (please refer to last week Notebook if you do not know how to use split) because words are separated with a space. For example, the following text has three words because they are separated by two spaces 7 am healthy'. Please, keep it is simple, and do not worry about the punctuation - create the list of unique words using set - for each word in the set, count the number of occurences by using a loop or any other method wish. At the end, you should have a list containing the list of occurences for all the words in the set - linally, convert the set of unique words to a list, and create the dictionary with the two lists of unique words and frequencies T To help you start on the assignent, I copied and pasted the code above here inport nitk nttk.dounlood ("book") print (n t k. corpus. qutenberg. rint'austen-enns, txt')) Using the while loop: - List all the presidents whose names contain the letter ' o ' - List all the presidents whose names do not contain the letter ' w ' - For each president, list the number of times the letter 'o' appears listuSPresidents=["George Washington", John Adams","Thomas Jefferson","James Madison", "James Monroo ", John Quincy Adams",Andrew Jackson","Martin Van Buren","Willam H. Harrison", "John Tyler", "James K. Polk", "Zachary Taylor","Millard Fillmore ""Franklin Pierco ",James Buchanan", "Abraham Lincoin", Andrew Johnson", "Ulysses S. Grant"; "Rutherford B. Hayes","James A. Garfield", "Chester A. Arthur", "Grover Cleveland"; "Benjamin Harrison", Grover Cleveland", "Willam Mckinley","Theodore Roosevelt", Willam H. Taft", Woodrow Wison;" "Warren G. Harding", "Calvin Coolidge", "Herbert Hoover", Franklin D. Rooseveit", Harry S. Truman", Dwight D. Eisenhower", "John F. Kennedy"; "tyndon B. Johnson"; Richard M. Nixon"; "Gerald R. Ford", "Jimmy Carter:"Ronald Reagan","George H. W. Bush;" "Bill Clinton", "George W, Bush";Barack Hussein Obama", Donald J. Trump"] To help you start on the assignoent, I copied and pasted the code above here Listuspresidents= "George Washington", "John Adaes", "Thomss Jefferson", "Jases Madison", "Janes Monroe", "Jahn Quincy Adans", Assignment (5 pts) Write a function that compares two mumbers and returns the smaller number. Assignment ( 5 pts) Following the example above, write the code that reads a file (ary text file of your choice), and copies it into another file. IsUSCurrentPresidentCatholic = True IsUSPreviousPresidentCatholic = False Change the values of the two variables above to print all the statements of the code.below if (IsUSCurrentPresidentCatholic) or (IsUSPreviousPresidentCatholic): print('The current USA president is catholic or the previous USA president is catholic') if (IsUSCurrentPresidentCatholic) and not(IsUSPreviousPresidentCatholic): print('The current USA president is catholic but the previous USA president is not catholic') elif not(IsUSCurrentPresidentCatholic) and (IsUSPreviousPresidentCatholic): print('The current USA president is not catholic but the previous USA president is catholic') else: print('The current USA president and the previous USA president are both catholic') else: print('The current USA president and the previous USA president are not catholic') Using the for loop: - List all the presidents whose names contain the letter ' a ' - List all the presidents whose names do not contain the letter ' m ' - For each president, list the number of times the letter 'a' appears listUSPresidents=["George Washington","John Adams","Thomas Jefferson","James Madison","James Monroe ", "John Quincy Adams","Andrew Jackson","Martin Van Buren", "Willam H. Harrison", "John Tyler","James K. Polk", "Zachary Taylor","Millard Fillmore","Franklin Pierce","James Buchanan","Abraham Lincoln","Andrew Johnson","Ulysses S. Grant","Rutherford B. Hayes","James A. Garfield", "Chester A. Arthur","Grover Cleveland","Benjamin Harrison", "Grover Cleveland","Williahn McKinley", "Theodore Roosevelt", William H. Taft," Woodrow Wilson", "Warren G. Harding","Calvin Coolidge","Herbert Hoover","Franklin D. Roosevelt","Harry S. Truman","Dwight D. Eisenhower", "John F. Kennedy","Lyndon B. Johnson","Richard M. Nixon","Gerald R. Ford","Jimmy Carter","Ronald Reagan", "George H. W. Bush","Bill Clinton", "George W. Bush", Barack Hussein Obama","Donald J. Trump"] NLTK includes a small selection of texts from the Project Gutenberg electronic text archive, which contains some 25,000 free electronic books, hosted at http:/Www.gutenberg.org/. See https://www.nltk.org/book/ch02.html for more information The code below loads the file identifiers in this corpus import nitk nltk download("book") print(nitk.corpus gutenberg.raw('austen-emma.txt')) emma = nitk corpus gutenberg. raw('austen-emmatxt'), replace("Vninin;" "), replace("Din; ; ") replace("7n"; ") emma We will focus on the novel Emma by Jane Austen Create a dictionary of words with their frequency. The key in the dictionary is the word, and the frequency is the value. Please, follow the steps below, to complete the assignment: - create the list of the words in the Emma novel. Think of using the split method of string (please refer to last week Notebook if you do not know how to use split) because words are separated with a space. For example, the following text has three words because they are separated by two spaces 7 am healthy'. Please, keep it is simple, and do not worry about the punctuation - create the list of unique words using set - for each word in the set, count the number of occurences by using a loop or any other method wish. At the end, you should have a list containing the list of occurences for all the words in the set - linally, convert the set of unique words to a list, and create the dictionary with the two lists of unique words and frequencies T To help you start on the assignent, I copied and pasted the code above here inport nitk nttk.dounlood ("book") print (n t k. corpus. qutenberg. rint'austen-enns, txt')) Using the while loop: - List all the presidents whose names contain the letter ' o ' - List all the presidents whose names do not contain the letter ' w ' - For each president, list the number of times the letter 'o' appears listuSPresidents=["George Washington", John Adams","Thomas Jefferson","James Madison", "James Monroo ", John Quincy Adams",Andrew Jackson","Martin Van Buren","Willam H. Harrison", "John Tyler", "James K. Polk", "Zachary Taylor","Millard Fillmore ""Franklin Pierco ",James Buchanan", "Abraham Lincoin", Andrew Johnson", "Ulysses S. Grant"; "Rutherford B. Hayes","James A. Garfield", "Chester A. Arthur", "Grover Cleveland"; "Benjamin Harrison", Grover Cleveland", "Willam Mckinley","Theodore Roosevelt", Willam H. Taft", Woodrow Wison;" "Warren G. Harding", "Calvin Coolidge", "Herbert Hoover", Franklin D. Rooseveit", Harry S. Truman", Dwight D. Eisenhower", "John F. Kennedy"; "tyndon B. Johnson"; Richard M. Nixon"; "Gerald R. Ford", "Jimmy Carter:"Ronald Reagan","George H. W. Bush;" "Bill Clinton", "George W, Bush";Barack Hussein Obama", Donald J. Trump"] To help you start on the assignoent, I copied and pasted the code above here Listuspresidents= "George Washington", "John Adaes", "Thomss Jefferson", "Jases Madison", "Janes Monroe", "Jahn Quincy Adans", Assignment (5 pts) Write a function that compares two mumbers and returns the smaller number. Assignment ( 5 pts) Following the example above, write the code that reads a file (ary text file of your choice), and copies it into another file

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Knowledge Discovery In Databases

Authors: Animesh Adhikari, Jhimli Adhikari

1st Edition

3319132121, 9783319132129

More Books

Students also viewed these Databases questions

Question

5. Explain the communication process.

Answered: 1 week ago

Question

1. What is nonverbal communication?

Answered: 1 week ago