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]
3 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]3 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
Which three pieces of information should be included in an artist statement? Select all that apply.
Dima020 [189]

Answer:

There is no answers given??

Explanation:

N/A

4 0
2 years ago
What is the synonym for term port?
Rus_ich [418]
The synonym for term port is seaport

3 0
2 years ago
Which wireless communication technology is most likely used when synchronizing device information to an automobile?
seropon [69]
Bluetooth is the most reasonable answer
8 0
3 years ago
Explain in details three security countermeasures you know.​
SpyIntel [72]

Answer:

The three options are:

1. Avoid sharing files and folders over the network without the permission of your administrators. You might fall in trouble otherwise.

2. Never share your credit card details with a third party through the internet. You can lose a lot of or all your money.

3. Always ensure that your password is strong enough or else your account can be hacked, And never share them with anybody.

Explanation:

Please check the answer.

4 0
2 years ago
A ___________ organizes related commands together, under a tab.
notsponge [240]
A menu bar organizes related commands together, under a tab.
So the answer is <span>b. menu bar</span>
8 0
3 years ago
Other questions:
  • How do media and networks interact
    11·1 answer
  • Which type of cable is described as a central conductor wire that is surrounded by insulating materials and placed inside a brai
    13·1 answer
  • Which sentences in the passage correctly describe a function?
    11·1 answer
  • Help with this chart please
    9·1 answer
  • What is the output of 1101 x 10 == 11000 + 10?
    12·1 answer
  • What are 3 ways to select an entire document?
    15·1 answer
  • What services are used to help speed the development and deployment of internal custom applications?
    8·2 answers
  • How do you award a brainliest
    8·2 answers
  • Explain the evolution of programming language​
    15·1 answer
  • Memory containing hardwired instructions that the computer uses when it boots up, before the system loads. In PCs the instructio
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!