in Technology by
What are negative indexes and why are they used?

1 Answer

0 votes
by
  • Negative indexes are the indexes from the end of the list or tuple or string.
  • Arr[-1] means last element of array Arr[]
arr = [1, 2, 3, 4, 5, 6]

#get the last element
print(arr[-1]) #output 6

#get the second last element
print(arr[-2]) #output 5

Related questions

0 votes
    What are Context Variables and why they are used in Talend?...
asked Mar 18, 2021 in Technology by JackTerrance
0 votes
    What are Python namespaces? Why are they used?...
asked Dec 6, 2020 in Technology by JackTerrance
0 votes
    What is meant by thermonuclear reactions and why are they so called ? Why are these reactions not useful for peaceful purposes ? Select the correct answer from above options...
asked Jan 2, 2022 in Education by JackTerrance
0 votes
    Two non-negative integers x and y are chosen at random with replacement. The probability that x2+y2 is divisible by 10, ... 50 D. 6 25 Select the correct answer from above options...
asked Nov 15, 2021 in Education by JackTerrance
0 votes
    Instantaneous power is negative, when the polarities of voltage and current are of __________ (a) opposite sign (b) ... GATE EC Exam, Network Theory MCQ (Multiple Choice Questions)...
asked Oct 19, 2021 in Education by JackTerrance
0 votes
    When candidates have only the condition of age, why should they give other information to Election Commission? Please answer the above question....
asked Aug 14, 2022 in Education by JackTerrance
0 votes
    Indexes are for improving the performance of queries, and, for some MarkLogic features, are required. (1)True (2)False...
asked Sep 23, 2021 in Technology by JackTerrance
0 votes
    Indexes are for improving the performance of queries, and, for some MarkLogic features, are required. (1)True (2)False...
asked Sep 23, 2021 in Technology by JackTerrance
0 votes
    If according to the hypothesis, the result should be positive, but in fact it is negative ... Hypothesis False Positive Hypothesis Specialized Hypothesis Consistent Hypothesis...
asked Mar 8, 2021 in Technology by JackTerrance
0 votes
    How a negative integer is stored in C Programming?...
asked Jan 17, 2021 in Technology by JackTerrance
+1 vote
    How a negative integer is stored in C-Programming?...
asked Nov 9, 2020 in Technology by JackTerrance
0 votes
    . Consider the following Dataframe Medals where row indexes are taken as the default values: House Gold Silver ... table in navol: Select the correct answer from above options...
asked Dec 29, 2021 in Education by JackTerrance
0 votes
    What are composite indexes? (a) Are those which are composed by database for its internal use (b) ... Answers, Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    How many types of indexes are there in sql server? (a) 1 (b) 2 (c) 3 (d) 4 The question was ... Index Definition in SQL topic in chapter Indexing and Hashing of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    Which statements are correct regarding indexes? (a) When a table is dropped, the corresponding indexes are ... Reads topic in section Concurrency Control of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
...