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
With which type of satellite is there a propagation delay?
Flauer [41]

Geostationary satellites have a high propagation delay.

8 0
3 years ago
You are writing an email to a potentional employer about a job opportunity. What can you do to make sure the email reflects your
Lina20 [59]
You want to use proper etiquette and be polite, do not call them by their first name and always refer to them as Mr., or Mrs. Use an extended vocabulary and do not talk about yourself.  If you have proper grammar, depending on the job, that can be seen as intelligence. And always use an appropriate closing that is respectful. Such as, Sincerely, John Doe.
4 0
4 years ago
Read 2 more answers
____ is a very fast network media. It contains multiple (sometimes several hundred) clear glass or plastic fibers, each about th
nikitadnepr [17]

<u>Fiber optic cable (FOC</u>) is a very fast network media and it comprises multiple clear glass or plastic fibers.

<h3>What is a fiber optic cable?</h3>

A fiber optic cable can be defined as a type of wired connector which are either made of glass or plastic and they are typically used for connecting one network device to another, so as to form a computer network and enable the continuous transmission of data between them.

In Computer technology, fiber optic cables (FOCs) are commonly produced through the use of several concentric layers of transparent material such as glass or plastic, with each having a slightly different index of refraction for light waves and about the thickness of a human hair.

Read more on fiberoptic cables here: brainly.com/question/116766

8 0
2 years ago
Which of the following defines code?
balu736 [363]

Answer:

A set of instructions, written by a programmer, that is used by computers to perform tasks

3 0
3 years ago
Select the correct answer.
goblinko [34]

Answer:

b

Explanation:

8 0
3 years ago
Other questions:
  • Emma opened a new document a Microsoft word and typed her assignment. She is now planning to save the documents for the first ti
    11·1 answer
  • What is a multipurpose network device?
    12·1 answer
  • Signs that a listener is paying attention include:
    10·2 answers
  • Write a program segment that simulates flipping a coin 25 times by generating and displaying 25 random integers, each of which i
    5·1 answer
  • If a firm's pages are not near the top of query results, customers may never discover its website. This has led to _____ becomin
    12·1 answer
  • What type of tool would be used to tighten a nut or bolt with an exact amount of twisting force?
    7·1 answer
  • What happens when i expose a disk to magnetic fields?​
    5·1 answer
  • What does a GPA show
    14·2 answers
  • What is the difference between * and **operator? in python ​
    9·1 answer
  • Who invented Satellites? What purpose does it serve? How has it impacted society today?
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!