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
How many months have 28 days?
Reika [66]

Answer:

All months of the year have at least 28 days, while February is the only month that is comprised of only 28 days (except for leap years)

5 0
3 years ago
2. Identify the diagram and define it.<br>13. What are pollen grains ?<br>4. What is an embryo?​
Virty [35]

Answer:

2. I can't help you with this question because i can't see the diagram

13.Pollen grains are microscopic bodies that have the male reproductive cell of the plant.

4. An Embryo is an organism in its early stage of development.

Explanation:

2. I can't help you with this question because i can't see the diagram

13.Pollen grains are microscopic bodies that have the male reproductive cell of the plant.

4. An Embryo is an organism in its early stage of development.

7 0
3 years ago
A group of cells is called a<br><br> Excel
arsen [322]

Answer:

Every worksheet is made up of thousands of rectangles, which are called cells. A cell is the intersection of a row and a column. ... You can also select multiple cells at the same time. A group of cells is known as a cell range

8 0
3 years ago
Match the data type to their correct explanations,
sergejj [24]

Answer:

I'm positive memo is "allows inserting a large amount of text including numbers" i just took the test on Plato and got everything wrong but that one

4 0
3 years ago
Read 2 more answers
One difference between multi-tasking using fork() versus using threads is that there is race condition among threads due to shar
MAXImum [283]

Answer:

vnn

Explanation:

7 0
3 years ago
Read 2 more answers
Other questions:
  • Explain free space allocation?
    9·1 answer
  • What does the Auto Fill tool do?
    15·2 answers
  • The network of satellites monitoring continental movement is referred to as
    7·1 answer
  • In the ____, or ad hoc, layouts configuration, there is no access point at the center of a cell.
    7·1 answer
  • Create a page using PHP for a business website that will ask the user to enter his or her name into text boxes and will display
    5·1 answer
  • A company has three (3) components in a system and requires all three to be operational for 24 hours, Monday to Friday. Failure
    5·1 answer
  • I need help, thank you
    5·1 answer
  • Um ok that makes sooo much sence
    11·2 answers
  • During the preventive maintenance phase of a project involving a hydraulic power system, an engineer must change a gasket on a p
    14·1 answer
  • Suppose that you have been asked to create an information system for a manufacturing plant that produces nuts and bolts of many
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!