answer.
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
Deffense [45]
1 year ago
15

BlockPy: #35.2) Animal Splits Write a function all_cats that consumes a comma-separated string of animals and prints whether all

of the animals have "cat" in their name. For example, the string "gerbil,catfish,dog,cat" would return False, but just "cat,catfish" would return True. If the function consumes an empty string, then it returns True. Call this function on a string of animals of your choice and print the result.
Computers and Technology
1 answer:
maks197457 [2]1 year ago
6 0

Answer:

def all_cats(data):

 dataArray = data.split(',')

 if(data==""):

   return True

 for i in dataArray:

   if('cat' not in i):

     return False

 

 return True

print(all_cats("gerbil,catfish,dog,cat"))

print(all_cats("cat,catfish"))

print(all_cats(""))

Explanation:

Step 1: define de function and the parameters

def all_cats(data):

Step 2: split the data by ,

dataArray = data.split(',')

Step 3 : validate if is an empty data and return true

if(data==""):

   return True

Step 4: Loop over de array data and validate if have cat in each data if not, then return false

for i in dataArray:

   if('cat' not in i):

     return False

Step 5 if have cat in each one return true

return True

Step 6 Validate with examples

print(all_cats("gerbil,catfish,dog,cat"))

print(all_cats("cat,catfish"))

print(all_cats(""))

You might be interested in
Write a function summarize_letters that receives a string and returns a list of tuples containing the unique letters and their f
marysya [2.9K]

Answer:

Explanation:

2nd part

def summarize_letters(string):

#Initializaing a empty dictionary

character_counter = {}

#converting all the characters to lowercase

string_lower = string.lower()

for i in string_lower:

#checking if the chacter presents in the dictionary then increase it by one and also to check if the character is alphabet

if i in character_counter and i.isalpha():

character_counter[i] = character_counter[i]+1

#checking if the character not present in the dictionary then assign 1

if i not in character_counter and i.isalpha():

character_counter[i] = 1

#converting the dictionary to list of tuples

list_of_tuples = [(k, v) for k, v in character_counter.items()]

return list_of_tuples

#3rd Part

#initializing a string of characters in alphabets

alphabets = 'a b b b b B A c e f g d h i j k B l m M n o p q r s P t u v w x y z'

print(summarize_letters(alphabets))

#importing the string module

import string

#pulling all the alphabets

alphabet = set(string.ascii_lowercase)

#checking if our hardcoded string has all the alphabets

if set(alphabets.lower()) >= alphabet:

print('The string ' +alphabets+' has all the letters in the alphabet ')

3 0
2 years ago
A competitive analysis of Google and Microsoft would look at their ________ . Both pay high salaries and offer great benefits. B
Yuki888 [10]

Answer:

personnel strategy

Explanation:

Competitive analysis is a process that involves relating the company to its environment. Competitive analysis helps identify the strengths and weaknesses of the company, as well as the opportunities and threats that affect it within its target market. This analysis is the basis on which the strategy will be designed, for this we must know or intuit as soon as possible:

The nature and success of the probable changes that the competitor may adopt.

The probable response of the competitor to the possible strategic movements that other companies may initiate.

The reaction and adaptation to the possible changes of the environment that may occur from the various competitors.

The competition is made up of companies that operate in the same market and perform the same function within the same group of customers regardless of the technology used for it. It is not, therefore, our competitor that manufactures a generic product like ours, but one that satisfies the same needs as we do with respect to the same target or consumer audience, for example, cinema can be the theme parks competition, since both are embedded in leisure.

4 0
1 year ago
Lance is at a bus station. His friend is using the ATM machine to withdraw some money. Lance notices a stranger deceptively watc
Blababa [14]

Answer:

The person watching Lances friend typing the ATM pin is an example of <u>"shoulder browsing"</u> and Lances friend should <u>"Change the ATM pin."</u>

<u />

<u>I hope this is the answer you were looking for!</u>

8 0
1 year ago
Read 2 more answers
A(n) key is the set of steps used to convert an unencrypted message into an encrypted sequence of bits that represent the messag
a_sh-v [17]

Answer:

Algorithm

Explanation:

Algorithm is a set of instructions designed to perform a specific task, an independent sequence of actions to be perform to solve a problem and instruction for performing a computation.

Algorithm is A(n) key set of steps used to convert an unencrypted message into an encrypted sequence of bits that represent the message; it sometimes refers to the programs that enable the cryptographic processes.

5 0
1 year ago
Read 2 more answers
Explain why each of the following names does or does not seem like a good variable name to represent a state sales tax rate.
tatyana61 [14]

a. stateTaxRate  - A good variable name because it represents what it holds, the state sales tax rate, without being too wordy. Also correctly capitalized in camelcase.

b. txRt  - A bad variable name because while short and simple, it is too hard to understand what the variable represents.

c. t  - A very bad variable name if you plan on using the variable often. Far too short and you will forget what it represents and is needed for.

d. stateSalesTaxRateValue  - A bad variable name because it is just too wordy. Cutting it down to A's variable name is much more reasonable

e. state tax rate  - A bad variable name and probably invalid because it has spaces in the name.

f. taxRate  - A good variable name if there are no other tax calculations other than state tax rate. Otherwise you would confuse state vs local tax rate or something, making it a bad variable name.

g. 1TaxRate  - A bad variable name because the number 1 has no reason being in the variable name. It doesn't add anything to the name.

h. moneyCharged - A bad variable name because it is not specific enough in explaining why the money is being charged and what for.

7 0
2 years ago
Other questions:
  • Based on a kc value of 0.150 and the data table given, what are the equilibrium concentrations of xy, x, and y, respectively?
    9·1 answer
  • Which act was used to penalize Sara? Sara was found to be in possession of a controlled substance for which she had no justifica
    5·1 answer
  • A ____ partition contains the data necessary to restore a hard drive back to its state at the time the computer was purchased an
    8·2 answers
  • Which one of the following is the best example of an authorization control? (a)- Biometric device (b)- Digital certificate (c)-A
    11·1 answer
  • The Paste Options button labeled ____ is used if you want the pasted chart not to be linked to the source document but you want
    9·1 answer
  • Information gathered from observing a plant grow 3 cm over a two-week period results in _______.a. inferences. b. variables. c.
    11·1 answer
  • What level of fault is the following example: North Lake Hospital followed all of the HIPAA policies and procedures for securing
    12·2 answers
  • Assign test_stat_72 to the value of the test statistic for the years 1971 to 1973 using the states in death_penalty_murder_rates
    11·1 answer
  • Which of the following option is correct about HCatalog?
    14·1 answer
  • 4. When emergency changes have to be made to systems, the system software may have to be modified before changes to the requirem
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!