What is an arbitrary element in Python?

I read about sets and see terms like "specific" elements and "arbitrary" elements. For example: "The remove method removes a specific element from the set, pop removes an arbitrary element." Can someone explain arbitrary elements?

+5
source share
4 answers

ar · bi · trar · y is an ˈärbəˌtrerē/adjective based on a random choice or personal whim, and not on any reason or system.

In the context of your question, an “arbitrary element” simply means an element not selected by you. From the point of view of the program, the element was chosen randomly and unpredictably.

Consider:

x = set([1,2]).pop()

x 1 2, , .

+8

.

remove .

. ,

+4

, - , . X + X = 2X, X - , .

0

, , pop .  nums = {4, 3, 3, 3, 3, 4, 5, 6, 1, -3}   ()  nums.add(-7)  nums.pop()   ()

: {1, 3, 4, 5, 6, -3} {3, 4, 5, 6, -7, -3}

0

Source: https://habr.com/ru/post/1662563/


All Articles