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
Help it's the last question quickkk​
aniked [119]
I would say the answer is b, but ⟟ might be wrong
7 0
3 years ago
How to have grey font in java swing.
tiny-mole [99]

Answer:

How do I change the font color in swing?

To set the font and color of JTextArea we can use the setFont() and setForeground() methods of the JTextArea . To create a font we must define the font name, the font style and its size. For the colors we can uses the constant color values defined by the Color class.

Explanation:

3 0
2 years ago
100 POINTS NEED ASAP PLEASE HELP
givi [52]

It is actually podcast! i took the quiz as well :)

3 0
3 years ago
Read 2 more answers
Computer are most wonderful creation of 21st century how ?​
son4ous [18]

Answer:

It can do all the functions at a speedy rate and also helps us to search and progress in our homes and businesses. A computer can therefore be called a calculator with a twist for not only does it perform fast calculations, but it also has other special characteristics.

Explanation:

hope it helps you

6 0
2 years ago
What types of forecast worksheets are available in Excel? Check all that apply.
Oksana_A [137]

Answer:

C, D

Explanation:

ya welcome:)

5 0
2 years ago
Read 2 more answers
Other questions:
  • How did the discovery of glossopteris support wegner's continental drift hypothesis?
    15·1 answer
  • Which is the highest level of the hierarchy of needs model?
    7·2 answers
  • Given the following business scenario, create a Crow's Foot ERD using a specialization hierarchy if appropriate. Granite Sales C
    12·1 answer
  • Write a static method named anglePairs that accepts three angles (integers), measured in degrees, as parameters and returns whet
    10·1 answer
  • Based upon what you know
    5·1 answer
  • A network security analyst received an alert about a potential malware threat on a user’s computer. What can the analyst review
    12·1 answer
  • Each computer on a network requires a unique way to identify itself and to refer to other computers. This is accomplished by usi
    8·1 answer
  • Weak Induction
    8·1 answer
  • Which statement describing the arcade games played in the 1970s is true?
    14·1 answer
  • What is contained in the Open Files section of Shared Folders? ​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!