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
The "fathers of the internet" are vinton cerf and ________.
Harrizon [31]
Robert E Kahn I hope this helps
8 0
3 years ago
Question 83 :Which type of fiber optic connector connects to a terminating device by pushing the connector into the terminating
STALIN [3.7K]

The Lucent connector(LC) is a type of fiber optic connector used here.

Explanation:

A Lucent connector (LC) is a type of fiber optic connector connects to a terminating device by pushing the connector into the terminating device and can be removed by depressing the tab on the connector and pulling it out of the terminating device.

It is a standard ceramic Ferrule connector and has good performance and is favored for single mode.

LC is a latched connector which have same handling capacities like SC. They have small flange on top similar to an RJ-45 connector that aids secure connection. It has a smaller connector housing and a smaller 1.25 mm ferrule.

3 0
3 years ago
Which of the following statements about constructors are true? Check all that apply.
Neko [114]

Answer:

a. Partly True

b. True

Explanation:

(a) "new" keyword or syntax is used for the constructors while working in Perl and Moose object system for Perl.

For Visual Basics .Net, keyword "New" is used

For Python, "___new___" is used which allocates memory for instance and receives class as an argument.

For Objective-C, "alloc" and "init" are used for constructor method. "alloc" allocates memory for the instance and "init" handles the bulk of initializing the instance. Whereas, the "new" keyword calls both "alloc" and "init" for class instance.

(b) A constructor does not return any value because it is called by the memory allocation and object initialization code  in the runtime and not directly by your code.

5 0
3 years ago
You can access various sites on the WWW by using hyperlinks or by
Vilka [71]
<span>or by following directions on screen </span>
5 0
3 years ago
A ___________ is similar to an intranet in that it uses internet technologies, but is developed for users outside the organizati
Vanyuwa [196]
The blank is extranet
I hope this helped!
6 0
3 years ago
Other questions:
  • Codio Challenge Activity PythonWe are passing in a list of numbers. You need to create 2 new lists in your chart, then put all o
    13·1 answer
  • Josh wants to convey his best wishes to johnathin for a meeting schedualed later diring the day. Which business documented would
    7·1 answer
  • You are photographing your friend in a local park which of the following might be supporting details you want to include in the
    6·1 answer
  • Who knows a website that can connect videos in your phone
    8·1 answer
  • A software EULA is an agreement related to which of the following?
    11·2 answers
  • Write a C++ program to count even and odd numbers in array. The array size is 50. The array elements will be entered by the user
    13·1 answer
  • Search..
    14·1 answer
  • What is output if the user enters -5?
    12·2 answers
  • How ssd is better than normal sata and pata HDD​
    11·1 answer
  • Does anybody have the answer for 2.19.6 checkerboard for codehs??
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!