Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 Implement a function average() that takes one parameter which is a string representing the name of a text file. The function should return the

1 Implement a function average() that takes one parameter which is a string representing the name of a text file. The function should return the average length of a word in the file.

The punctuation in the file should be removed prior to determining the average length of a word in the file. For the purposes of this question the valid punctuation symbols are commas (.), periods (.), exclamation marks (!), question marks (?), semicolons (), and colons (). If the file is empty, the function should return 0.

2. Write a function wordsWith Letter() that takes as a parameter a string representing the name of a text file and a letter to use to check against the words. The function returns a list of all the words in the file that contain that letter. Make sure to remove all punctuation (i.e. all commas, question marks, periods, colons, and semicolons) before determining whether any words are duplicated so that the punctuation won't interfere with the process. Capitalization should be ignored. The information below shows how you would call the function words With Letter () and what it would show for a couple of sample executions. Duplicate words are okay. If you have time, think about how could you eliminate duplicate words. This is what the output looks like when running against the samples files: >>>print(worthlattersale1101.txt') bal, animation's emphasize, animation and animation', 'a, 'broad', liberal', 'arte', 'animation career, tanke, dopaul', 'animation's animation program, animation', 'a', 'able', 'draw.creati vely innovative, animation and", pitation program, omphasise, art, animation, creativit Yand', criticall, are foundation, animating, and take are', 'a', 'broad", "intellectual nd'. creative, liberalland'. can', 'latest animation, software and hand-drawn, capture nd', 'a', 'an', emphasis interdisciplinary'. Learning and!, exploration Beint wordswithtottereautof 10%.txt, doo! 1 Implement a function average() that takes one parameter which is a string representing the name of a text file. The function should return the average length of a word in the file.

The punctuation in the file should be removed prior to determining the average length of a word in the file. For the purposes of this question the valid punctuation symbols are commas (.), periods (.), exclamation marks (!), question marks (?), semicolons (), and colons (). If the file is empty, the function should return 0. 2. Write a function wordsWith Letter() that takes as a parameter a string representing the name of a text file and a letter to use to check against the words. The function returns a list of all the words in the file that contain that letter. Make sure to remove all punctuation (i.e. all commas, question marks, periods, colons, and semicolons) before determining whether any words are duplicated so that the punctuation won't interfere with the process. Capitalization should be ignored. The information below shows how you would call the function words With Letter () and what it would show for a couple of sample executions. Duplicate words are okay. If you have time, think about how could you eliminate duplicate words. This is what the output looks like when running against the samples files: >>>print(worthlattersale1101.txt') bal, animation's emphasize, animation and animation', 'a, 'broad', liberal', 'arte', 'animation career, tanke, dopaul', 'animation's animation program, animation', 'a', 'able', 'draw.creati vely innovative, animation and", pitation program, omphasise, art, animation, creativit Yand', criticall, are foundation, animating, and take are', 'a', 'broad", "intellectual nd'. creative, liberalland'. can', 'latest animation, software and hand-drawn, capture nd', 'a', 'an', emphasis interdisciplinary'. Learning and!, exploration Beint wordswithtottereautof 10%.txt, doo! The BA in Animation emphasizes animation principles and animation production within a broad Liberal Arts context. In 2016, Animation Career Review ranked DePaul Animation the #16 animation program in the U.S. The student in the Animation BA will be able to draw creatively innovative connections between animation and other subjects of inspiration. This program emphasizes the art of animation, creativity, and critical thinking. Students are introduced to the foundation skills of animating, and then take the production sequence, in which they are expected to bring a broad intellectual and creative viewpoint, influenced by their Liberal Studies courses and electives, to their work. Students can experiment with the latest in animation software, tools, and technologies including hand-drawn, 3D, stop motion, motion capture, motion control, and green screen studios. This is an extremely flexible degree with an emphasis on interdisciplinary learning and self-directed exploration. 10:04 el LTE Done sampleFile2 (4 of 4) This is a simple doc to test. III 10:04 el LTE Done lab8 (3 of 4) def average(filename): pass def wordsWithLetter(filename, letter): pass print(average('sampleFile1.txt')) print(average ('sampleFile2.txt')) print(wordsWithLetter sampleFile1.txt', 'a')) print(wordswithletter( 'sampleFile2.txt', 'c')) III

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

Step: 3

blur-text-image

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

App Inventor

Authors: David Wolber, Hal Abelson

1st Edition

1449397484, 9781449397487

More Books

Students also viewed these Programming questions

Question

What is a (a) dichotomous variable? (b) binary variable?

Answered: 1 week ago

Question

Evaluate each logarithm to four decimal places. log 0.257

Answered: 1 week ago