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
kherson [118]
3 years ago
10

Complete the method/function so that it converts dash/underscore delimited words into camel casing. The first word within the ou

tput should be capitalized only if the original word was capitalized. Specifications Challenge.toCamelCase(str) given a string with dashes and underscore, convert to camel case Parameters str: String - String to be converted Return Value String - String without dashes/underscores and camel cased Examples str Return Value "the-stealth-warrior" "theStealthWarrior" "A-B-C" "ABC"

Computers and Technology
1 answer:
nata0808 [166]3 years ago
3 0

Answer:

I am writing a Python program. Let me know if you want the program in some other programming language.

def toCamelCase(str):  

   string = str.replace("-", " ").replace("_", " ")  

   string = string.split()

   if len(str) == 0:

       return str

   return string[0] + ''.join(i.capitalize() for i in string[1:])

   

print(toCamelCase("the-stealth-warrior"))

Explanation:

I will explain the code line by line. First line is the definition of  toCamelCase() method with str as an argument. str is basically a string of characters that is to be converted to camel casing in this method.

string = str.replace("-", " ").replace("_", " ") . This statement means the underscore or dash in the entire are removed. After removing the dash and underscore in the string (str), the rest of the string is stored in string variable.  

Next the string = string.split()  uses split() method that splits or breaks the rest of the string in string variable to a list of all words in this variable.

if len(str) == 0 means if the length of the input string is 0 then return str as it is.

If the length of the str string is not 0 then return string[0] + ''.join(i.capitalize() for i in string[1:])  will execute. Lets take an example of a str to show the working of this statement.

Lets say we have str = "the-stealth-warrior". Now after removal of dash in by replace() method the value stored in string variable becomes the stealth warrior. Now the split() method splits this string into list of three words the, stealth, warrior.

Next return string[0] + ''.join(i.capitalize() for i in string[1:])  has string[0] which is the word. Here join() method is used to join all the items or words in the string together.

Now i variable moves through the string from index 1 and onward and keeps capitalizing the first character of the list of every word present in string variable from that index position to the end.  capitalize() method is used for this purpose.

So this means first each first character of each word in the string starting from index position 1 to the end of the string is capitalized and then all the items/words in string are joined by join() method. This means the S of stealth and W of warrior are capitalized and joined as StealthWarrior and added to string[0] = the which returns theStealthWarrior in the output.

You might be interested in
Which of the following groups would an animal with an exoskeleton, segmented body, and jointed appendages belong to???
Annette [7]
All arthropods have exoskeletons, like insects, spiders and crustaceans.
7 0
3 years ago
Read 2 more answers
A data _____ is a collection of data from a variety of sources used to support decision-making applications and generate busines
Blababa [14]

Answer:

warehouse

Explanation:

A bit similar to a database, a data warehouse is a collection or large store of data from different sources that businesses and organization can use to make intelligent business decisions. The data sources for a data warehouse are typically databases from different vendors and architectures.

Data warehouses are typically data repositories used by organizations for data analysis and reporting purposes.

3 0
3 years ago
when using screwdrivers you should always be aware that the screwdriver blade might slip out of the slot and strike you in the .
ELEN [110]

When using screwdrivers you should always be aware that the screwdriver blade might slip out of the slot and strike you in the:

  • -hand
  • -eye
  • -mouth

<h3>What is a Screwdriver?</h3>

A screwdriver is said to be a kind of a modern tool that can come in a manual or powered type and it is one that is often used for turning screws.

Note that a typical simple screwdriver is one that has a handle as well as a shaft and it is also one that is often ending in a tip where a given user can be able to put their hands into the screw head before turning the handle.

Therefore, when using screwdrivers you should always be aware that the screwdriver blade might slip out of the slot and strike you in the:

  • -hand
  • -eye
  • -mouth

Learn more about screwdrivers  from

brainly.com/question/20717091

#SPJ4

3 0
1 year ago
Define the terms data and information ??​
lora16 [44]

Answer:

Data is an individual unit that contains raw materials which do not carry any specific meaning. Information is a group of data that collectively carries a logical meaning. Data doesn't depend on information. Information depends on data. It is measured in bits and bytes.

5 0
3 years ago
Read 2 more answers
Given a list of integers. find the size of the list
dlinn [17]

The size of a list of integers can be found using python as follows;

size = len(list1)

<h3>How to find the size of a list using python?</h3>

The size of a list can be found using the len() function in python.

According to the question, the list is an integer.

Therefore, let's use an example below:

list1 = [1, 2, 1, 3, 6, 7, 8, 9, 4, 7, 8, 6, 4]

size = len(list1)

print(size)

Therefore,  the size of a list of integers can be found using the len() function in python.

learn more on python here: brainly.com/question/14989942

#SPJ1

6 0
2 years ago
Other questions:
  • Which type of security threat installs to a computer without the user's knowledge and then monitors all computer activity?
    12·2 answers
  • Does anyone take bca on plato
    11·1 answer
  • As with country citizenship, with digital citizenship comes _____.
    14·2 answers
  • In the accompanying figure, the split double arrow mouse pointer____.
    7·1 answer
  • Write a algorithm to attend birthday party​
    8·2 answers
  • Which website can help you find antivirus software ?
    10·1 answer
  • In this lab, you will create a programmer-defined class and then use it in a Java program. The program should create two Rectang
    14·1 answer
  • Describe the different
    12·1 answer
  • For this activity, you will practice being both proactive and reactive to bugs. Both are necessary to get rid of errors in code.
    5·1 answer
  • What variation pairs a new employee with an employee who has been with the company for 20 years?
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!