ScholarMatic | 24/7 Homework Help

ScholarMatic Will Help You Write Your Essays and Term Papers

Answered » You can buy a ready-made answer or pick a professional tutor to order an original one.

I need to begin with the Python code below:

by | Nov 28, 2023 | computer science

I need help with an assignment. I need to begin with the Python code below:.   

alphabet = “abcdefghijklmnopqrstuvwxyz”   

test_dups = [“zzz”,”dog”,”bookkeeper”,”subdermatoglyphic”,”subdermatoglyphics”] 

test_miss = [“zzz”,”subdermatoglyphic”,”the quick brown fox jumps over the lazy dog”] 

def histogram(s):

   d = dict()

   for c in s:

     if c not in d:

        d[c] = 1

     else:

        d[c] += 1

   return d 

I need to make 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.  

Then I need to implement has_duplicates by creating a histogram using the histogram function above.My implementation should use the counts in the histogram to decide if there are any duplicates. 

I need to make a loop over the strings in the provided test_dups list. Then I need to print each string in the list and whether or not it has any duplicates based on the return value of has_duplicatesfor that string. For example, the output for “aaa” and “abc” would be the following. 

aaa has duplicates

abc has no duplicates 

At last, I need to print a line like one of the above for each of the strings in test_dups. 

Part 2 

I need to make 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. 

My 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. 

I need to make a loop over the strings in list test_miss and call missing_letters with each string. Then I must 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 bcdefghijklmnopqrstuvwxyz 

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. 

abcdefghijklmnopqrstuvwxyz uses all the letters 

I need to print a line like one of the above for each of the strings in test_miss. 

Can you please 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. 

I will also need the output from running my program. 

ScholarMatic: Explanation & Answer

Your ready answer from a verified tutor is just a click away for as little as $14.99


  

Click Order Now to get 100% Original Answer Customized to your instructions!

HOME TO CERTIFIED WRITERS

Why Place An Order With Us?

  • Certified Editors
  • 24/7 Customer Support
  • Profesional Research
  • Easy to Use System Interface
  • Student Friendly Pricing

Have a similar question?

PLAGIRAISM FREE PAPERS

All papers we provide are well-researched, properly formatted and cited.

TOP QUALITY

All papers we provide are well-researched, properly formatted and cited.

HIGHLY SECURED

All papers we provide are well-researched, properly formatted and cited.

ScholarMatic: Get Started

Assignment Writing Service

Feel safe and secure when placing an order on our portal!
Fruitful cooperation begins with solid guarantees, and we are professional enough to promise perfect results. Let’s get it started!