Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

question # 6 multiple choice what is the missing line of code? >>> sent…

Question

question # 6
multiple choice
what is the missing line of code?

>> sentence = \programming is fun!\
>>

gra
sentence2:6
sentence2:5
sentence3:5
sentence3:6

Explanation:

Brief Explanations

In Python, string slicing string[start:stop] extracts characters from start (inclusive) to stop (exclusive). For the string "Programming is fun!", to get 'gra', the start index should be 3 (since indexing starts at 0, 'P' is 0, 'r' is 1, 'o' is 2, 'g' is 3) and the stop index should be 6 to include 'g', 'r', 'a' but not the next character.

Answer:

D. sentence[3:6]