Post

Python Programming
Python Programming@PythonPr·
Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!
Python Programming tweet media
English
45
7
110
11.2K
Earnest Codes
Earnest Codes@Earnesto037·
@PythonPr Answer:C). tho. This is due to Python's string slicing: Strings use 0-based indexing. The slice [2:5] extracts characters starting from index 2 (inclusive) up to, but not including, index 5 (exclusive). In the string "python": p is at index 0 y is at index 1 t is at index 2
English
2
0
9
504
Jana
Jana@BratDotAI·
@PythonPr In Python slicing, the start index is inclusive and the end index is exclusive. "python"[2:5] returns the characters at indices 2, 3, and 4: t, h, o.
English
0
0
2
162
Omo Yewa
Omo Yewa@AceKelm·
@PythonPr That's python slicing. Slices from item in index 2 a d stops at index 5, excluding the last item. Therefore, the answer is B. tho.
English
0
0
2
421
Coding Computing Coach
Coding Computing Coach@CodingComputing·
@PythonPr Answer: B Solution: This is an application of slicing in python. As you know, [] is used for indexing, ie, picking out one item from a list or string. But there is more to it. [] can also be used for slicing, ie, to extract multiple items. Let's see how it works +
English
1
0
2
268
Zac Nielsen
Zac Nielsen@itszacnielsen·
@PythonPr B) tho This is the Python slicing method will stat from index 0, and include everything except the final index number.
English
0
0
1
102
Gonada Inc.
Gonada Inc.@GonadaInc·
@PythonPr The output of the above Python code is B. tho because the index was sliced
English
0
0
0
0
Paylaş