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
20
7
114
10.5K
Earnest Codes
Earnest Codes@Earnesto037·
@PythonPr (a) [2, 3] Understand that; Python uses zero-based indexing and negative indexing for lists, where: Positive indices start from 0 at the beginning of the list. Negative indices start from -1 at the end of the list. For the given list nums = [1, 2, 3, 4]: 1 is at index 0 (or -4)
English
1
0
11
441
Kamal Gurjar
Kamal Gurjar@KamalGurjar8·
@PythonPr Answer: A) [2, 3] Explanation: Negative slicing counts from the end. -3 points to 2, -1 points to 4 (exclusive), so the slice includes elements at indices 1 and 2 → [2, 3].
English
0
0
10
619
Coding Computing Coach
Coding Computing Coach@CodingComputing·
@PythonPr Answer: A Solution: This is an application of slicing and negative indices. You must be familiar with the usual indexing that starts from 0 (starting from the left). Negative indexing is a cool feature of python. It allows you to count backwards (from the right). Eg +
English
1
0
4
645
Nwaeze Joshua Nonso
Nwaeze Joshua Nonso@OnPointKonceptz·
@PythonPr The slice includes everything from index -3 up to, but not including, index -1. This leaves the elements [2, 3]. Answer=A
English
0
0
3
485
laso
laso@lasitolas·
@PythonPr A...consider slicing and indices. Where list start 0 and -1
English
0
0
1
232
Raniaemran
Raniaemran@Raniaemran80042·
@PythonPr I wanna see the comments. What is wrong ?
English
0
0
0
22
Paylaş