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
Alla [95]
4 years ago
11

1. Assume that word is a variable of type String that has been assigned a value . Assume furthermore that this value always cont

ains the letters "dr" followed by at least two other letters. For example: "undramatic", "dreck", "android", "no-drip".
Assume that there is another variable declared , drWord, also of type String . Write the statements needed so that the 4-character substring word of the value of word starting with "dr" is assigned to drWord. So, if the value of word were "George slew the dragon" your code would assign the value "drag" to drWord.

2. Assume that sentence is a variable of type String that has been assigned a value . Assume furthermore that this value is a String consisting of words separated by single space characters with a period at the end. For example: "This is a possible value of sentence."

Assume that there is another variable declared , firstWord, also of type String . Write the statements needed so that the first word of the value of sentence is assigned to firstWord. So, if the value of sentence were "Broccoli is delicious." your code would assign the value "Broccoli" to firstWord.
Computers and Technology
1 answer:
s2008m [1.1K]4 years ago
4 0

Answer:

1.word = "George slew the dragon"

startIndex = word.find('dr')

endIndex = startIndex + 4

drWord = word[startIndex:endIndex]

2. sentence = "Broccoli is delicious."

sentence_list = sentence.split(" ")

firstWord = sentence_list[0]

Explanation:

The above snippet is written in Python 3.

1. word is initialized to a sentence.

Then we find the the occurence of 'dr' in the sentence which is assign to startIndex

We then add 4 to the startIndex and assign it to endIndex. 4 is added because we need a length of 4

We then use string slicing method to create a substring from the startIndex to endIndex which is assigned to drWord.

2. A string is assigned to sentence. Then we split the sentence using sentence.split(" "). We split based on the spacing. The inbuilt function of split returns a list. The first element in the list is assigned to firstWord. List uses zero based index counting. So. firstWord = sentence_list[0] is use to get first element.

You might be interested in
A bin contains 100 sty le a notebooks, 100 style b notebooks, and 100 style c notebooks. antoine will select 3 notebooks from th
emmasim [6.3K]
<span>The answer is Ten.  Substituting numbers for letters, available selections are 111, 112, 113, 122, 123, 133, 222, 223, 233, 333.  Note that, for example, 112, 121, and 211 are considered as the same selection.
</span>AAA, BBB, CCC, <span>AAB, AAC, </span><span>BBC, </span><span>ABB, ACC, </span><span>CCB & ABC.</span>
7 0
3 years ago
Explain briefly the use of the computers in the advertising area​
olya-2409 [2.1K]

Answer:

Brainly.con

Explanation:

5 0
3 years ago
Why are businesses willing to provide more goods at higher prices
irina1246 [14]
It depends on what kinda "goods" your talking about clothes they don't have a choice cause material costs a lot overall it's their way of getting a lot of money because some people do fall for the prices and their is a lot of competition around some businesses
5 0
3 years ago
The best way to share criticism is to ______. a. write it in the break room b. talk it about with all your coworkers c. talk abo
ICE Princess25 [194]

Answer:

C.

Explanation:

6 0
3 years ago
Read 2 more answers
1) Draw an activity diagram according to the below flow of event:
stiv31 [10]

Answer:

Yyyyttttrrttyuynynnyj6jj

6 0
3 years ago
Other questions:
  • How many mustangs are built every day
    13·2 answers
  • Josh's boss asked him to write a letter to their customers explaining some upcoming price increases. But Josh was in a hurry to
    8·2 answers
  • What answer best explains why improper netiquette is considered dangerous? Individuals who violate user policies are often charg
    14·2 answers
  • A friend was just promoted to a new job that requires part-time travel, and he has also been promised a new laptop after his fir
    10·1 answer
  • business information management professionals also perform duties of _ information system professionals
    11·1 answer
  • Which graphic file format is used for commercial purposes.
    10·1 answer
  • Write if true or false
    11·1 answer
  • Help plz (will give brainliest)
    9·1 answer
  • Does any of yall play rob lox?
    5·2 answers
  • Privacy, anonymity, and freedom of expression are all interrelated.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!