Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

help Question 12 (20 points) Write a function named analyz count of telephone numbers that are in each area code. eAreaCodes that takes a list

image text in transcribed

help

Question 12 (20 points) Write a function named analyz count of telephone numbers that are in each area code. eAreaCodes that takes a list of telephone numbers and computes the The function analyzeAreacodes takes one parameter phones, a list of telephone numbers where each number is a string of the form 999-999-9999. The leftmost three digits are the area code. Thus the telephone number 123-456-7899 has area code 123. The function analyzeAreacodes returns a dictionary where each key is an area code in list phones, and the corresponding value is the count of telephone numbers in the area code. For example, the following 55, erantec n v9s2-esc.sacp ire0- 49-3568 979-406 042, "982-779-31) print(analyzeAreacodes(phones)) ('982': 2, ee: 1, 979: 1) Question 13 (20 points) Write a function named linestats that finds the number of consonant and vowel letters on each line of a file and writes those statistics to a corresponding line of a new file, separated by a space. Definitions: A vowel letter is on e of: a, e, 1, o u, along with the corresponding uppercase letters. A consonant letter is not a vowel letter The function linestats takes two parameters 1. inFile, a string, the name of an input file that exists before lineStats is called 2. outFile, a string the name of an output fnle that inestats creates and writes to Important: The input file contains only upper and lower case letters and white space (no punctuation marks or other special characters) For example, if the following is the content of the file mary.txt: Mary had a Little Lamb Its fleece was white as snow And everywhere that Mary went The Lamb was sure to go The following function call: >>> inFile = 'mary, txt, >> outFile'maryStats.txt >> lineStats(inFile, outFile) should create the file maryStats. txt with the content 12 6 14 9 17 8 11 7

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

Database Concepts

Authors: David M. Kroenke

1st Edition

0130086509, 978-0130086501

More Books

Students also viewed these Databases questions