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"]
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.

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

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 15:30, ninja12302
Some of the items below indicate the steps required to move a slide to a different location in a presentation. select those steps and indicate the order in which they should be performed to move the slide. (for example, if an item describes what you do first, select 1.) included in the list are items that are not part of the process. for these items, select n/a, an abbreviation for not applicable. 1 — first 2 — second 3 — third 4 — fourth 5 — fifth 6 — sixth n/a — not applicable drag the slide to the desired place. enter the slide position desired. hold the mouse button down. select move from the tools menu. select the slide. switch to the notes view.
Answers: 3
image
Computers and Technology, 23.06.2019 20:40, bobby3350
On nba 2k 19, every time i try to join a my park game, it leads ro a website telling my dad that he needs ps plus. i already have ps plus though. how do i fix this?
Answers: 2
image
Computers and Technology, 24.06.2019 16:00, bsrlee1115
Which type of cloud computing offers easily accessible software and applications on the machines
Answers: 1
image
Computers and Technology, 24.06.2019 16:50, yedida
Ideally, the backrest is tilted back slightly, so when you turn the wheel your shoulders are the seat.
Answers: 2
You know the right answer?
Start with the following Python code. alphabet = ""
test_dups = ["zzz","dog","bookkeeper","s...

Questions in other subjects: