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
An Operating System is an application just like any other applications we use on our computers. What makes an Operating System s
tatyana61 [14]

Answer: An operating system(OS) is an interface between the hardware and the user. An OS is built so that it could support other software. OS is a system software which is used to support other application softwares.

Explanation:

An operating system handles all the hardware of the system and allows users access to those hardware components with the help of application softwares.

An OS consist of many libraries and APIs which allows programmers to write and execute codes. There are many types of OS such as real time, multitasking, multi programming OS.

The OS is responsible for allocating memory, managing the hardware, distributing resources across different processors in an distributed system.

So all these features makes them different from application software. The OS is responsible allocating memory and hardware resources to these softwares.

3 0
3 years ago
Which of the following, when used in conjunction with hyperlinks, can be useful for easily navigating a Word document? : *
Valentin [98]
Caption is a best answer i hope its work
7 0
3 years ago
When computing effect size, the sample size is ________.
NNADVOKAT [17]
Sample size  is not taken into account

8 0
3 years ago
Which is a example of fixed expense <br><br> -food<br> -clothing<br> -entertainment<br> -rent
Artemon [7]
Salutations!

<span>Which is an example of fixed expense?

Rent is an example of fixed expense, It doesn't matter whether you sell a widget or produce thousand of them, you must still pay the rent in any </span><span>circumstances.
</span>
Hope I helped.
6 0
4 years ago
Read 2 more answers
Why do designers use tonal shading?
Simora [160]

Designers use tonal shading because tonal shading gives a drawling dimension.


Hopefully this will help you out! :)

4 0
3 years ago
Read 2 more answers
Other questions:
  • Derek found that the CPU was running several processes. While Derek was looking at Task Manager, the computer crashed. Derek res
    15·2 answers
  • Why is a DNS cache poisoning attack dangerous? Check all that apply. A. Errrr...it's not actually dangerous. B. It allows an att
    12·1 answer
  • Which of these describes the functionality of a database? Check all of the boxes that apply.
    10·2 answers
  • Explain why an IT department and a user support group may disagree about the responsibility for the development of end-user appl
    8·1 answer
  • What is software infrastructure?
    15·1 answer
  • What term is commonly used to refer to HTML formatting?
    5·1 answer
  • Which type of address is the ip address 232. 111. 255. 250?.
    11·1 answer
  • Which of the following are responsibilities of information security management? Defining the protection required for systems and
    14·1 answer
  • How does a fully integrated Data and Analytics Platform enable organizations to convert data into consumable information and ins
    15·1 answer
  • Write the following short piece of code in python:
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!