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]
2 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]2 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
There is a file "IT4983" in my home (personal) directory. I don’t know my current working directory. How can I find out the file
RoseWind [281]

Answer and Explanation:

Find / -name "IT4983"

See what it will do is it will find the file named IT4983 in the root directory.

run this commmand with sudo just in case for permission issues.

then it will give you the location of that file we want to find.

 

Or

$ file /home/IT4983 ( you can type this command from whichever directory you are )

output : IT4983 , ASCII TEXT

3 0
2 years ago
Which decimal value (base 10) is equal to the binary number 1012?
GaryK [48]

Answer:

The decimal value of 101₂² base 2 = 25 base 10

Explanation:

The number 101₂² in decimal value is found as follows;

101₂ × 101₂ = 101₂ + 0₂ + 10100₂

We note that in 101 + 10100 the resultant 2 in the hundred position will have to be converted to a zero while carrying over 1 to the thousand position to give;

101₂ + 0₂ + 10100₂ = 11001₂

Therefore;

101₂² =  11001₂

We now convert the result of the square of the base 2 number, 101², which is 11001₂ to base 10 as follows;

Therefore converting 11001₂ to base 10 gives;

11001₂= 1 × 2⁴ + 1 × 2³ + 0 × 2² + 0 × 2 ¹ + 1 × 2⁰

Which gives;

16 + 8 + 0 + 0 + 1 = 25₁₀.

7 0
1 year ago
Why are smartphones and tablets capable of handling rich content and interactivity?
NikAS [45]

Answer:

Explanation:

With the advance in technology, smartphones, and tablets are built to meet the ever-increasing needs of users.

Smartphones are mobile phones that also have internet connectivity, they can be used to make calls and perform many tasks just like the conventional desktop. Smartphones and tablets are indeed considered computers because they also process inputs in form of commands and they produce outputs.

Smartphones and tablets are capable of handling rich content and interactivity because:

1. Wireless synchronization with other devices: Just like desktops, laptops, they can interact with other devices, and can receive and also send information doesn't matter the distance.

2. They have Internet connectivity.

3. They have strong hardware, good storage capacity.

4. They have inbuilt software and are capable of accepting other software and programs.

5. They are built with an appealing user interface.

6. Just as computers have processors, smartphones and tablets also have processors to ensure their speed at processing informations.

3 0
2 years ago
What are the differences between a policy, a standard, and a practice? What are the three types of security policies? Where woul
hjlf

Answer:

  • The difference between a policy, a standard and a practice is as follow:
  1. Policy: It can be defined as the written instructions that describe proper behavior.
  2. Standard: It can be defined as the detailed statement of what must be done to comply with policy.
  3. Practice: It can be defined as the examples of actions that would comply with policy.
  • The three types of security policies are:
  • Enterprise Information Sec. Policy (EISP) : High level policy that sets the strategic direction, scope, and tone for the organization's security efforts. Use: It is used to support the mission, vision and direction of the organization and sets the strategic direction, scope and tone for all security efforts
  • Issue Specific Sec. Policy (ISSP) : An organizational policy that provides detailed, targeted guidance to instruct all members of the organization in the use of a resource, such as one of its processes or technologies. Use: It is used to support routine operations and instructs employees on the proper use of these technologies and processes
  • System Specific Sec. Policy (SysSP): Organizational policies that often function as standards or procedures to be used wen configuring or maintaining systems. SysSPs can be separated into two general groups-managerial guidance and technical specifications- but may be written as a single unified document. Use: It is used as a standard when configuring or maintaining systems.
  • ISSP policy would be needed to guide the use of the web, email and use of personal use of office equipment.

3 0
1 year ago
assume that name is a variable of type stirng that has been assigned a value write an expression whose value is the last charact
Snezhnost [94]

Answer:

The most straight forward way to do it: in general string are zero index based array of characters, so you need to get the length of the string, subtract one and that will be the last character, some expressions in concrete languages would be:

In Python:

name = "blair"

name[len(name) - 1]

In JavaScript:

name = "blair"

name[name.length - 1]

In C++:

#include <string>

string name = "blair";

name[name.length() - 1];

7 0
1 year ago
Other questions:
  • U.S. industries like steel, computers, and energy need to be protected from foreign competition to ensure which of the following
    6·2 answers
  • Julie bought a house for $315,000 and has a $285,000 mortgage. she claims she has $315,000 in equity. is she correct? if not, ho
    12·2 answers
  • Which of the following is true of information systems?
    15·1 answer
  • 4.2.3: Basic while loop expression. Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Fol
    6·2 answers
  • Consider a DASH system for which there are N video versions (at N different rates and qualities) and N audio versions (at N diff
    8·1 answer
  • When trying to improve performance of a slow system, you notice in Task Manager that the superfetch service is using a high perc
    11·1 answer
  • When pasting an object which has been copied from a different slide, where on the slide does the object paste, assuming nothing
    15·1 answer
  • Consider the packets exchanged in TCP connection setup between Host A and Host B. Assume that Host A's initial sequence number i
    7·1 answer
  • A variable like userNum can store a value like an integer. Extend the given program to print userNum values as indicated. (1) Ou
    15·1 answer
  • Calvin is an aspiring graphic designer. He wants to achieve Adobe Certified Expert certification in software that will be helpfu
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!