Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

question # 1 multiple choice you have previously used slicing with stri…

Question

question # 1
multiple choice
you have previously used slicing with strings.
what is the output?
str = abcdef
print(str2:5)
o cdef
o cde
o bcd
o bcde

Explanation:

Step1: Understand string slicing

In Python, string slicing str[a:b] extracts characters from index a (inclusive) to index b (exclusive).

Step2: Identify indices

Here, str = 'abcdef', a = 2 and b = 5. The characters at indices 2, 3, 4 are 'c', 'd', 'e' respectively.

Answer:

B. cde