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
Deffense [45]
3 years 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]3 years 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
In ANSI standard C(1989) code - this is what we are teaching- declarations can occur in a for statementas in
tatiyna

Answer:

true is the answer to this

8 0
3 years ago
Pls help me pls I’m struggling
evablogger [386]

Answer:Turn Right () Degrees (block)

The turn right () degrees block is a Motion block and a stack block. The block turns its sprite's direction the specified amount of degrees clockwise.

6 0
3 years ago
What X coordinate does the center of a game begin at?
kotegsom [21]

A. 0

I am not entirely sure, I am not much of a coder(well I am but I don’t code often) so I hope this helps!

5 0
3 years ago
Before using the data type string, the program must include the header file ____.
notsponge [240]
Hello <span>Enriqueliz5443</span><span>

Answer: Before using the data type string, the program must include the header file string


Hope this Helps!
-Chris</span>
3 0
3 years ago
Which of the following Office Online apps is most effective for creating multi-media presentations
lubasha [3.4K]
PowerPoint would be best for multi-media presentations. It allows you to include pictures and videos to make your presentation more effective. You can also select the appropriate themes, color schemes, animations, and transitions to make it more appealing as well.
4 0
3 years ago
Other questions:
  • To extend the bottom border of a hyperlink across the complete width of a navigation list, change the ____ property of each hype
    9·1 answer
  • When creating a mail merge, you must insert all of the items from your data source into your merged document. Truth or false ?
    6·2 answers
  • COMPUTER FUNDIMENTAL HELP 20 POINTS!!!
    5·1 answer
  • An administrative assistant types a document, saves, and prints. The assistant is using _____.
    13·1 answer
  • PLZ HELP WITH SPEED i need the answer<br><br> WILL GIVE BRAINLIEST
    15·1 answer
  • PLEASE HELP. I’ll mark you BRAINLIST <br> Please read the comment under this question
    9·1 answer
  • Which among the following if absent, a computer is not complete.
    6·2 answers
  • Name the default Package of java<br>​
    8·2 answers
  • Slayyy queeen slayyy
    12·2 answers
  • HELP NEEDED PLEASE HELP!!! ​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!