1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Aleks [24]
2 years ago
7

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.

Computers and Technology
1 answer:
vichka [17]2 years ago
3 0

Answer:

Explanation:

The python code for the question is attached in the image below.

The objective here is to write a code in python with 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.

SEE BELOW FOR THE CODE.

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

def has_duplicates():

   for string in test_dups:

       dictionary=histogram(string)

       duplicates=False

       for ch in dictionary.keys():

           if dictionary[ch] > 1:

               duplicates=True

               break

       if duplicates==True:

           print(string,"has duplicates")

       else:

           print(string,"has no duplicates")

def missing_letters(string):

   answer=""

   for ch in alphabet:

       if ch not in string:

           answer=answer+ch

   return answer

print("__________________________________________")

print(" Calling has_duplicates() function")

print("__________________________________________")

has_duplicates()

print("\n______________________________________________")

print("Calling missing_letters() function in for loop")

print("______________________________________________")

for i in test_miss:

   answer=missing_letters(i)

   if len(answer)>=1:

       print(i,"is missing letters",answer)

   else:

       print(i,"uses all the letters")

You might be interested in
Why would students most likely need to collect data? Check all that apply
n200080 [17]
Well I would think all of them in some way. For the first one, students need to collect data (whether it’s mathematical, scientific, etc.) to answer a question. For the second one, they may need to know how much money is in there bank account or they may need to calculate a sale to order the item. For the third one, they may need statistical data to support a position. For the last one, a student could use technological data to be able to solve their problem sorting documents.
5 0
3 years ago
Read 2 more answers
When an interviewer asks "tell me about yourself", you should tell them about your childhood past. please select the best answer
Yanka [14]

In the interview when the candidate is asked about yourself then telling about childhood past is not correct. Therefore the given statement is false.

<h3>What is an interview?</h3>

An interview is an interaction or a conversation between an employer and the interested candidate. In the conversation the interviewee is asked about their education, family background, and work experiences.

When an interviewer ask about tell me about yourself, then the interviewee should not tell about their childhood past, rather the interviewee should give few information about their family, education, and working.

Therefore, the given statement is false.

Learn more about interview, here:

brainly.com/question/13073622

#SPJ1

7 0
1 year ago
Which term represents a computational instruction stored in computer memory?
lys-0071 [83]
A computational instruction with operands is command so computational instructionis just a opcode.
B. opcode
4 0
3 years ago
Read 2 more answers
In the context of computer crimes, those who attempt to destroy the infrastructure components of governments and financial insti
elixir [45]

In the context of computer crimes, those who attempt to destroy the infrastructure components of governments and financial institutions are known as <u>d. cyber terrorists</u>.

<u>Explanation</u>:

Cyber crime means crime committed with the help of computer and internet. Cyber terrorism means crime that causes damage to infrastructure components of financial institutions and government office and causes threat to the society.

Cyber terrorists are person who involve in cyber terrorism. The systems used in the governments and financial institutions should be protected with hardware and software to avoid cyber terrorism.

This kind of cyber terrorism is very dangerous, as they hack the system and destroy the valuable information stored in it.

5 0
2 years ago
You have been tasked with designing an Ethernet network. Your client needs to implement a very high-speed network backbone betwe
lorasvet [3.4K]

Answer:

A and C

Explanation:

From the above scenario, the Ethernet standards that meet the above guidelines are:

A. 1000BaseSX; and

C. 10GBaseSR.

Cheers

3 0
3 years ago
Other questions:
  • How do type declaration statements for simple variables affect the readability of a language, considering that some languages do
    10·1 answer
  • katherine has work experience of seven years as a graphic designer and photographer. she wants to now redirect her career to web
    5·2 answers
  • PLEASE HURRY What data unit is addressed based on the IP address of the recipient? a. packet b. frame c. segment d. section
    9·2 answers
  • Două numere a și b sunt numite generatoare ale unui număr natural n dacă a∙b+[a/b]=n, unde s-a notat cu [c] partea întreagă a nu
    7·1 answer
  • _____ creates a border or space that separates information.
    14·1 answer
  • Technician A says that volatility describes how hard it is for gasoline to evaporate. Technician B says that Reid vapor pressure
    8·1 answer
  • a. Fill in the blanks with suitable words: A software that controls and manages all the activities of the computer ... b. A soft
    13·1 answer
  • Which of these is not a valid form<br>layout in Microsoft Access?​
    11·1 answer
  • Write a Java program that will be able to generate the sample table below.
    5·1 answer
  • If you're connected to a switch and your NIC is in promiscuous mode, what traffic would you be able to capture
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!