subject

Start with the following Python code. alphabet = "" test_dups = ["zzz","dog","bookkeeper","subderma toglyphic","subdermatoglyphics"] test_miss = ["zzz","subdermatoglyphic","the quick brown fox jumps over the lazy dog"] # From Section 11.2 of: # Downey, A. (2015). Think Python: How to think like a computer scientist. Needham, Massachusetts: Green Tree Press. def histogram(s): d = dict() for c in s: if c not in d: d[c] = 1 else: d[c] += 1 return d Copy the code above into your program but write all the other code for this assignment yourself. Do not copy any code from another source. Part 1 Write a function called has_duplicates that takes a string parameter and returns True if the string has any repeated characters. Otherwise, it should return False. Implement has_duplicates by creating a histogram using the histogram function above. Do not use any of the implementations of has_duplicates that are given in your textbook. Instead, your implementation should use the counts in the histogram to decide if there are any duplicates. Write a loop over the strings in the provided test_dups list. Print each string in the list and whether or not it has any duplicates based on the return value of has_duplicates for that string. For example, the output for "aaa" and "abc" would be the following. aaa has duplicates abc has no duplicates Print a line like one of the above for each of the strings in test_dups. Part 2 Write a function called missing_letters that takes a string parameter and returns a new string with all the letters of the alphabet that are not in the argument string. The letters in the returned string should be in alphabetical order. Your implementation should use a histogram from the histogram function. It should also use the global variable alphabet. It should use this global variable directly, not through an argument or a local copy. It should loop over the letters in alphabet to determine which are missing from the input parameter. The function missing_letters should combine the list of missing letters into a string and return that string. Write a loop over the strings in list test_miss and call missing_letters with each string. Print a line for each string listing the missing letters. For example, for the string "aaa", the output should be the following. aaa is missing letters If the string has all the letters in alphabet, the output should say it uses all the letters. For example, the output for the string alphabet itself would be the following. uses all the letters Print a line like one of the above for each of the strings in test_miss. Submit your Python program. It should include the following. The provided code for alphabet, test_dups, test_miss, and histogram. Your implementation of the has_duplicates function. A loop that outputs duplicate information for each string in test_dups. Your implementation of the missing_letters function. A loop that outputs missing letters for each string in test_miss. Also submit the output from running your program. Your submission will be assessed using the following Aspects. Does the program include a function called has_duplicates that takes a string parameter and returns a boolean? Does the has_duplicates function call the histogram function? Does the program include a loop over the strings in test_dups that calls has_duplicate on each string? Does the program correctly identify whether each string in test_dups has duplicates? Does the program include a function called missing_letters that takes a string parameter and returns a string parameter? Does the missing_letters function call the histogram function? Does the missing_letters function use the alphabet global variable directly? Does the program include a loop over the strings in test_miss that calls missing_letters on each string? Does the program correctly identify the missing letters for each string in test_miss, including each string that "uses all the letters"?

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:00
Create a word problem that involves calculating the volume and surface area of a three-dimensional object. cube: surface area 6 s2 , volume s3
Answers: 3
question
Computers and Technology, 22.06.2019 21:50
Given int variables k and total that have already been declared, use a while loop to compute the sum of the squares of the first 50 counting numbers, and store this value in total. thus your code should put 11 + 22 + 33 + + 4949 + 50*50 into total. use no variables other than k and total.
Answers: 2
question
Computers and Technology, 22.06.2019 22:30
One of your customers wants you to build a personal server that he can use in his home. one of his concerns is making sure he has at least one backup of their data stored on the server in the event that a disk fails. you have decided to back up his data using raid. since this server is for personal use only, the customer wants to keep costs down. therefore, he would like to keep the number of drives to a minimum. which of the following raid systems would best meet the customer's specifications? a. raid 0 b. raid 1 c. raid 5 d. raid 10
Answers: 3
question
Computers and Technology, 23.06.2019 03:00
Your business be in google top rank.more the rank more the business leads.for best seo and digital marketing services be confident to contact you can get best seo solutions by assistance experts provide digital marketing, website development, seo expert services and social media internet seo expert services your branding solutions. seo expert services ,best seo expert services,online seo expert services,
Answers: 3
You know the right answer?
Start with the following Python code. alphabet = "" test_dups = ["zzz","dog","bookkeeper","subderma...
Questions
question
Mathematics, 05.09.2020 23:01
question
Mathematics, 05.09.2020 23:01
Questions on the website: 13722360