Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Problem 9

If Python did not provide the set container, but you needed one in your program, what type of container could you use instead? Explain your answer.

Problem 10

Write a program that reads in two files and prints out, in sorted order, all words that are common to both of them.

Problem 11

Can a dictionary have two keys with the same value? Two values with the same key?

Problem 11

Write a program that reads in a text file, converts all words to lowercase, and prints out all words in the file that contain the letter a, the letter b, and so on. Build a dictionary whose keys are the lowercase letters, and whose values are sets of words containing the given letter.

Problem 12

Define a dictionary that maps month name abbreviations to month names.

Problem 13

A multiset is a collection in which each item occurs with a frequency. You might have a multiset with two bananas and three apples, for example. A multiset can be implemented as a dictionary in which the keys are the items and the values are the frequencics. Write Python functions union, intersection, and difference that take two such dictionaries and return a dictionary representing the multiset union, intersection, and difference. In the union, the frequency of an item is the sum of the frequencies in both sets. In the intersection, the frequency of an item is the minimum of the frequencies in both sets. In the difference, the frequency of an item is the difference of the frequencies in both sets, but not less than zero.

Problem 13

Define a dictionary with five entries that maps student identification numbers to their full names.

Problem 14

Define a dictionary that maps the course numbers of the courses you are currently taking to their corresponding course titles.

Problem 14

Write a "censor" program that first reads a file with "bad words" such as "sex", "drugs", "C++", and so on, places them in a set, and then reads an arbitrary text file. The program should write the text to a new text file, replacing each letter of any bad word in the text with an asterisk.

Problem 16

Write a function that takes a string argument and returns a. the most common letter in the string. b. a set consisting of the lowercase letters not contained in the string. c. a dictionary containing the number of times cach lctter occurs in the string.

Access millions of textbook solutions in one place

  • Access over 3 million high quality textbook solutions
  • Access our popular flashcard, quiz, mock-exam and notes features
  • Access our smart AI features to upgrade your learning
Get Vaia Premium now
Access millions of textbook solutions in one place

Recommended explanations on Computer Science Textbooks