{"id":19149,"date":"2021-11-29T03:04:32","date_gmt":"2021-11-29T03:04:32","guid":{"rendered":"https:\/\/assignmenttutors.net\/blog\/python-assign-code-h-w-computer-science-homework-help\/"},"modified":"2021-11-29T03:04:32","modified_gmt":"2021-11-29T03:04:32","slug":"python-assign-code-h-w-computer-science-homework-help","status":"publish","type":"post","link":"https:\/\/assignmenttutors.net\/blog\/python-assign-code-h-w-computer-science-homework-help\/","title":{"rendered":"Python assign code h\/w | Computer Science homework help"},"content":{"rendered":"<div>\n<p>\u00a0<\/p>\n<p>Start with the following Python code.\u00a0\u00a0<\/p>\n<p>alphabet = &#8220;abcdefghijklmnopqrstuvwxyz&#8221;\u00a0\u00a0\u00a0<\/p>\n<p>test_dups =\u00a0[&#8220;zzz&#8221;,&#8221;dog&#8221;,&#8221;bookkeeper&#8221;,&#8221;subdermatoglyphic&#8221;,&#8221;subdermatoglyphics&#8221;]\u00a0<\/p>\n<p>test_miss = [&#8220;zzz&#8221;,&#8221;subdermatoglyphic&#8221;,&#8221;the quick brown fox jumps over the lazy dog&#8221;]\u00a0<\/p>\n<p># From Section 11.2 of:\u00a0<\/p>\n<p># Downey, A. (2015). Think Python: How to think like a computer scientist. Needham, Massachusetts: Green Tree Press.\u00a0<\/p>\n<p>def histogram(s):<br \/>\u00a0 \u00a0 \u00a0d = dict()<br \/>\u00a0 \u00a0 \u00a0for c in s:<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 if c not in d:<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0d[c] = 1<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 else:<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0d[c] += 1<br \/>\u00a0 \u00a0 \u00a0return d\u00a0<\/p>\n<p>Copy the code above into your program but write all the other code for this assignment yourself. <strong>Do not copy any code from another source.\u00a0<\/strong><\/p>\n<p><strong>Part 1\u00a0<\/strong><\/p>\n<p>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.\u00a0\u00a0<\/p>\n<p>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.\u00a0<\/p>\n<p>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 &#8220;aaa&#8221; and &#8220;abc&#8221; would be the following.\u00a0<\/p>\n<p>aaa has duplicates<br \/>abc has no duplicates\u00a0<\/p>\n<p>Print a line like one of the above for each of the strings in test_dups.\u00a0<\/p>\n<p><strong>Part 2\u00a0<\/strong><\/p>\n<p>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 <strong>not<\/strong> in the argument string. The letters in the returned string should be in alphabetical order.\u00a0<\/p>\n<p>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.\u00a0<\/p>\n<p>The function missing_letters should combine the list of missing letters into a string and return that string.\u00a0<\/p>\n<p>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 &#8220;aaa&#8221;, the output should be the following.\u00a0<\/p>\n<p>aaa is missing letters bcdefghijklmnopqrstuvwxyz\u00a0<\/p>\n<p>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.\u00a0<\/p>\n<p>abcdefghijklmnopqrstuvwxyz uses all the letters\u00a0<\/p>\n<p>Print a line like one of the above for each of the strings in test_miss.\u00a0<\/p>\n<p>Submit your Python program. It should include the following.\u00a0<\/p>\n<ul>\n<li>The provided code for alphabet, test_dups, test_miss, and histogram.\u00a0<\/li>\n<li>Your implementation of the has_duplicates function.\u00a0<\/li>\n<li>A loop that outputs duplicate information for each string in test_dups.\u00a0<\/li>\n<li>Your implementation of the missing_letters function.\u00a0<\/li>\n<li>A loop that outputs missing letters for each string in test_miss.\u00a0<\/li>\n<\/ul>\n<p>Also submit the output from running your program.\u00a0<\/p>\n<p>Your submission will be assessed using the following Aspects.<\/p>\n<ol>\n<li>Does the program include a function called has_duplicates that takes a string parameter and returns a boolean?<\/li>\n<li>Does the has_duplicates function call the histogram function?\u00a0<\/li>\n<li>Does the program include a loop over the strings in test_dups that calls has_duplicate on each string?\u00a0<\/li>\n<li>Does the program correctly identify whether each string in test_dups has duplicates?\u00a0<\/li>\n<li>Does the program include a function called missing_letters that takes a string parameter and returns a string?\u00a0<\/li>\n<li>Does the missing_letters function call the histogram function?<\/li>\n<li>Does the missing_letters function use the alphabet global variable directly?<\/li>\n<li>Does the program include a loop over the strings in test_miss that calls missing_letters on each string?<\/li>\n<li>Does the program correctly identify the missing letters for each string in test_miss,\u00a0including each string that &#8220;uses all the letters&#8221;?<\/li>\n<\/ol>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0 Start with the following Python code.\u00a0\u00a0 alphabet = &#8220;abcdefghijklmnopqrstuvwxyz&#8221;\u00a0\u00a0\u00a0 test_dups =\u00a0[&#8220;zzz&#8221;,&#8221;dog&#8221;,&#8221;bookkeeper&#8221;,&#8221;subdermatoglyphic&#8221;,&#8221;subdermatoglyphics&#8221;]\u00a0 test_miss = [&#8220;zzz&#8221;,&#8221;subdermatoglyphic&#8221;,&#8221;the quick brown fox jumps over the lazy dog&#8221;]\u00a0 # From Section 11.2 of:\u00a0 # Downey, A. (2015). Think Python: How to think like a computer scientist. Needham, Massachusetts: Green Tree Press.\u00a0 def histogram(s):\u00a0 \u00a0 \u00a0d = dict()\u00a0 \u00a0 \u00a0for c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[],"class_list":["post-19149","post","type-post","status-publish","format-standard","hentry","category-homework-help"],"_links":{"self":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts\/19149","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/comments?post=19149"}],"version-history":[{"count":0,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts\/19149\/revisions"}],"wp:attachment":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/media?parent=19149"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/categories?post=19149"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/tags?post=19149"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}