Question

Question 12 (20 points) Write a function named inverse that takes a single parameter, a dictionary. In this key is a student, represented by a string. The value of each key is a list of courses, each represented by a string, in which the student is enrolled. dictionary each The function inverse should compute and return a dictionary in which each key is a course and the associated value is a list of students enrolled in that course For example, the following would be correct input and output. >>> student-courses {Elise:[], Nelson, :[cs100,MATH = print(inverse(student courses) ) cs100: [Nelsontin MATH111: [NelsonJ) Question 13 (20 points) Write a function named fileStats. The function fileStats takes two parameters 1. inFile, a string that is the name of an input file 2. outFile, a string that is the name of an output file The function fileStats should read and analyze each line of the input file and write two statistics, separated by a space, about the line to a corresponding line of the output file. The two statistics for each line are 1. the number of words 2. the number of digits (digits are the characters in positive integers: 0, 1,2..) For example, if the file monthStats.txt contains the following lines February has 28 days or 29 in a leap year January and March have 31 days April has 30 days Then the function call filestats (monthStats.txt, monthStatsout.txt) should produce an output file monthStatsOut.txt with the following content 104 6 2 4 2

help

0 0
Add a comment Improve this question Transcribed image text
Answer #1

student_courses = {'Elise' : [],
'Nelson' : ['CS100','MATH111'],
'Justin' : ['CS100']}
print(student_courses)
print()

saved Python 3.6.1 (default, Dec 2015, 13:05:11) [GCC 4.8.2] on linux shareは run main.py ##inverse function declaration ##tak

Please comment if struck!!

Good Luck!!

Thanks!!

Add a comment
Know the answer?
Add Answer to:
help Question 12 (20 points) Write a function named inverse that takes a single parameter, a...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • in pyhton For example, the following would be correct input and output >» student_courses ('Elise:[1. Nelson :['cS1e0, MATH111']. 'Justin:t CS100']) >>> print (inve...

    in pyhton For example, the following would be correct input and output >» student_courses ('Elise:[1. Nelson :['cS1e0, MATH111']. 'Justin:t CS100']) >>> print (inverse(student_courses)) ('cs100': ['Nelson', Justin'], 'MATH111: [Nelson']) Question 13 (20 points) Write a function named filestats. The function filestats takes two parameters 1. 2. inFile, a string that is the name of an input file outFile, a string that is the name of an output file The function ftlestats should read and analyze each line of the input file...

  • Python 3 Write a function named inverse that takes a single parameter, a dictionary. In this...

    Python 3 Write a function named inverse that takes a single parameter, a dictionary. In this dictionary each key is a student, represented by a string. The value of each key is a list of courses, each represented by a string, in which the student is enrolled. The function inverse should compute and return a dictionary in which each key is a course and the associated value is a list of students enrolled in that course. For example, the following...

  • Python 3.6 Question 12 (20 points) Write a function named wordLengths. The function wordLengths takes two...

    Python 3.6 Question 12 (20 points) Write a function named wordLengths. The function wordLengths takes two parameters: 1. inFile, a string that is the name of an input file 2. outFile, a string that is the name of an output file The input file exists when wordLengths is called; wordLengths must create the file outFile. The input file contains only letters and white space For each line of the input file, wordLengths should identify the length of the longest word...

  • Write a function named mostFrequent that takes two parameters: 1. inFile, a string that is the...

    Write a function named mostFrequent that takes two parameters: 1. inFile, a string that is the name of an input file 2. outFile, a string that is the name of an output file The input file inFile exists when mostFrequent is called; mostFrequent must create outFile. The input file contains only lower case letters and white space. The function mostFrequent identifies the letter(s) that appear most frequently on each line of inFile and writes them to a corresponding line of...

  • Python 3.6 Question 12 (2θ points) write a function named uniqueWords that counts how many different...

    Python 3.6 Question 12 (2θ points) write a function named uniqueWords that counts how many different words there are in each line of an input file and writes that count to a corresponding line of an output file. The input file already exists when uniqueWords is called. uniquewords creates the output file. Input. The function uniquewords takes two parameters: ◆ inFile, a string that is the name of text file that is to be read. The file that inFile refers...

  • Using python Question 13 (20 points) Write a function named Linestats that finds the number of...

    Using python 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 one of a, e, i, 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...

  • project-8a Write a function named count_letters that takes as a parameter a string and returns a...

    project-8a Write a function named count_letters that takes as a parameter a string and returns a dictionary that tabulates how many of each letter is in that string. The string can contain characters other than letters, but only the letters should be counted. The string could even be the empty string. Lower-case and upper-case versions of a letter should be part of the same count. The keys of the dictionary should be the upper-case letters. If a letter does not...

  • Problem 3 Write a function named repeat_words that takes two string parameters: 1. in_file: the name...

    Problem 3 Write a function named repeat_words that takes two string parameters: 1. in_file: the name of an input file that exists before repeat_words is called 2. out_file: the name of an output file that repeat_words creates Assume that the input file is in the current working directory and write the output file to that directory. For each line of the input file, the function repeat_words should write to the output file all of the words that appear more than...

  • C++ Write a function parseScores which takes a single input argument, a file name, as a string. Your function should read each line from the given filename, parse and process the data, and print the r...

    C++ Write a function parseScores which takes a single input argument, a file name, as a string. Your function should read each line from the given filename, parse and process the data, and print the required information. Your function should return the number of student entries read from the file. Empty lines do not count as entries, and should be ignored. If the input file cannot be opened, return -1 and do not print anything.     Your function should be named...

  • Python 3 Write a function named starCounter that takes three parameters: 1. a dictionary named starDictionary....

    Python 3 Write a function named starCounter that takes three parameters: 1. a dictionary named starDictionary. Each key in starDictionary is the name of a star (a string). Its value is a dictionary with two keys: the string 'distance' and the string 'type'. The value associated with key 'distance' is the distance from our solar system in light years. The value associated with key 'type' is a classification such as 'supergiant' or 'dwarf'. 2. a number, maxDistance 3. a string,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT