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.
Answer:
c. open the file, read/write/save data, close the file
Explanation:
Answer:
Written in Python
import math
degreesF = float(input("Enter a temperature in degrees Fahrenheit: "))
degreesC = round(5 * (degreesF - 32)/9,1)
print(degreesC)
Explanation:
The following header allows you to use Math.Round() method in Python
import math
The following prompts the user for temperature in degrees Fahrenheit
degreesF = float(input("Enter a temperature in degrees Fahrenheit: "))
The following calculates the degree Celsius equivalent and also round it up
degreesC = round(5 * (degreesF - 32)/9,1)
The following prints the degree Celsius equivalent
print(degreesC)
Answer:
The correct answer to this question is given below in the explanation section.
Explanation:
The correct answer to this question is : 4.
When you run this program in Java. The output produce by this program is 4
The given code is:
import java.util.ArrayList;
public class arrayList7
{
public static void main(String[] args) {
ArrayList one = new ArrayList ();
Integer count=3;
count=count+1;
one.add(2);
one.add(count);
System.out.println(one.get(1));
}
}
This code store the value in ArrayList one variable. It first adds 2 at zero indexes and 4 at first index. When you print the value at index one, you will get the output 4. because the count variable contains 4. If you want to print 2, then you specify the print statement that prints the value at index zero. eg.
System.out.println(one.get(0));
The largest geologic time frame is Eon.