Computers and Technology
Computers and Technology, 09.09.2019 19:10, aris35

#now let's make things a little more challenging.
#
#last exercise, you wrote a function called word_count that
#counted the number of words in a string essentially by
#counting the spaces. however, if there were multiple spaces
#in a row, it would incorrectly add additional words. for
#example, it would have counted the string "hi david" as
#4 words instead of 2 because there are two additional
#spaces.
#
#revise your word_count method so that if it encounters
#multiple consecutive spaces, it does *not* count an
#additional word. for example, these three strings should
#all be counted as having two words:
#
# "hi david"
# "hi david"
# "hi david"
#
#other than ignoring consecutive spaces, the directions are
#the same: write a function called word_count that returns an
#integer representing the number of words in the string, or
#return "not a string" if the input isn't a string. you may
#assume that if the input is a string, it starts with a
#letter word instead of a space.
#write your function here!
#below are some lines of code that will test your function.
#you can change the value of the variable(s) to test your
#function with different inputs.
#
#if your function works correctly, this will originally
#print:
#word count: 4
#word count: 2
#word count: not a string
#word count: not a string
#word count: not a string
print("word count: ", word_count("four words are here! "))
print("word count: ", word_count("hi david"))
print("word count: ", word_count(5))
print("word count: ", word_count(5.1))
print("word count: ", word_count(true))

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 12:10, drelisech6467
Linux is distributed under gnu gpl. why is this important? a. it ensures that only torvalds can profit from the sale of linux b. it prevents unknowledgeable users from downloading programs they don't know how to operate. c. it provides protection for the developers who created linux. d. it states that anyone can copy, modify, and share the program if changes are made public.
Answers: 1
image
Computers and Technology, 23.06.2019 12:00, clevelandjaniya1
Which of these is a benefit of using objects in a powerpoint presentation? a. collaborators can create the external files while you create and edit the slide show. b. you can easily change the theme and design of the presentation. c. you can have older data in the source file while having up-to-date data in the presentation. d. collaborators can easily share the presentation.
Answers: 2
image
Computers and Technology, 23.06.2019 16:00, CalCDanG
What is the biggest difference between section breaks and regular page breaks? section breaks are more difficult to add than page breaks. section breaks make it easier for you to view the document as an outline. section breaks allow you to have areas of the document with different formatting. section breaks are smaller than regular page breaks.
Answers: 2
image
Computers and Technology, 24.06.2019 09:50, trenrain
Create a string list. 2. use console. readline() to collect values of firstname, lastname, street, city, state, zip, save them to list. 3. write a simple linq statement, call method uppercasewords() to change first letter to uppercase. 4. create a foreach statment to display the information. public static string uppercasewords(string value) { char[] array = value. tochararray(); if (array. length > = 1) { if (char. islower(array[0])) { array[0] = char. toupper(array[0]); } } for (int i = 1; i < array. length; i++) { if (array[i - 1] == ' ') { if (char. islower(array[i])) { array[i] = char. toupper(array[i]); } } } return new string(array);
Answers: 3
Do you know the correct answer?
#now let's make things a little more challenging.
#
#last exercise, you wrote a functi...

Questions in other subjects:

Konu
Mathematics, 14.10.2019 14:30
Konu
History, 14.10.2019 14:30