python a set of all numeric types.do pop(),not output randomly [duplicate]
This question already has an answer here:
Set.pop() isn't random?
2 answers
当一个集合中的全部类型为数值时,pop()将升序输出,这一点不明白,集合不是无序的吗?
translation:
When all the types in a collection are numeric, pop() will output in ascending order.I don't know why, isn't the set unordered?
s = 2,5,3,7,0
for i in range(5):
print(s.pop())
output:
0
2
3
5
7
python
marked as duplicate by B. M., jpp
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 14 '18 at 14:37
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Set.pop() isn't random?
2 answers
当一个集合中的全部类型为数值时,pop()将升序输出,这一点不明白,集合不是无序的吗?
translation:
When all the types in a collection are numeric, pop() will output in ascending order.I don't know why, isn't the set unordered?
s = 2,5,3,7,0
for i in range(5):
print(s.pop())
output:
0
2
3
5
7
python
marked as duplicate by B. M., jpp
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 14 '18 at 14:37
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
I have found a similar question in this topic, it could help you stackoverflow.com/questions/1867861/…
– Baptiste Gavalda
Nov 14 '18 at 14:22
1
See stackoverflow.com/questions/21017188/set-pop-isnt-random
– B. M.
Nov 14 '18 at 14:34
add a comment |
This question already has an answer here:
Set.pop() isn't random?
2 answers
当一个集合中的全部类型为数值时,pop()将升序输出,这一点不明白,集合不是无序的吗?
translation:
When all the types in a collection are numeric, pop() will output in ascending order.I don't know why, isn't the set unordered?
s = 2,5,3,7,0
for i in range(5):
print(s.pop())
output:
0
2
3
5
7
python
This question already has an answer here:
Set.pop() isn't random?
2 answers
当一个集合中的全部类型为数值时,pop()将升序输出,这一点不明白,集合不是无序的吗?
translation:
When all the types in a collection are numeric, pop() will output in ascending order.I don't know why, isn't the set unordered?
s = 2,5,3,7,0
for i in range(5):
print(s.pop())
output:
0
2
3
5
7
This question already has an answer here:
Set.pop() isn't random?
2 answers
python
python
asked Nov 14 '18 at 14:05
WangTanxuWangTanxu
214
214
marked as duplicate by B. M., jpp
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 14 '18 at 14:37
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by B. M., jpp
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 14 '18 at 14:37
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
I have found a similar question in this topic, it could help you stackoverflow.com/questions/1867861/…
– Baptiste Gavalda
Nov 14 '18 at 14:22
1
See stackoverflow.com/questions/21017188/set-pop-isnt-random
– B. M.
Nov 14 '18 at 14:34
add a comment |
I have found a similar question in this topic, it could help you stackoverflow.com/questions/1867861/…
– Baptiste Gavalda
Nov 14 '18 at 14:22
1
See stackoverflow.com/questions/21017188/set-pop-isnt-random
– B. M.
Nov 14 '18 at 14:34
I have found a similar question in this topic, it could help you stackoverflow.com/questions/1867861/…
– Baptiste Gavalda
Nov 14 '18 at 14:22
I have found a similar question in this topic, it could help you stackoverflow.com/questions/1867861/…
– Baptiste Gavalda
Nov 14 '18 at 14:22
1
1
See stackoverflow.com/questions/21017188/set-pop-isnt-random
– B. M.
Nov 14 '18 at 14:34
See stackoverflow.com/questions/21017188/set-pop-isnt-random
– B. M.
Nov 14 '18 at 14:34
add a comment |
1 Answer
1
active
oldest
votes
It doesn't occur if the numbers are higher
>>> l=list(range(655360, 6553600))
>>> for _ in range(20):
... el = ra.choice(l)
... s.add(el)
... print(el)
...
3589721
2762448
1543072
4489208
5381194
4181645
1470069
6256052
5833067
6288785
3707357
1414093
3347945
1358111
1754489
4503096
3424305
2233038
4817376
3941735
>>> for _ in range(10):
... print(s.pop())
...
4181645
6288785
1358111
1543072
3424305
6256052
4503096
5381194
1414093
2233038
It's a Python implementation detail and you should not rely on it.
As recommended in the comments, please see this answer
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It doesn't occur if the numbers are higher
>>> l=list(range(655360, 6553600))
>>> for _ in range(20):
... el = ra.choice(l)
... s.add(el)
... print(el)
...
3589721
2762448
1543072
4489208
5381194
4181645
1470069
6256052
5833067
6288785
3707357
1414093
3347945
1358111
1754489
4503096
3424305
2233038
4817376
3941735
>>> for _ in range(10):
... print(s.pop())
...
4181645
6288785
1358111
1543072
3424305
6256052
4503096
5381194
1414093
2233038
It's a Python implementation detail and you should not rely on it.
As recommended in the comments, please see this answer
add a comment |
It doesn't occur if the numbers are higher
>>> l=list(range(655360, 6553600))
>>> for _ in range(20):
... el = ra.choice(l)
... s.add(el)
... print(el)
...
3589721
2762448
1543072
4489208
5381194
4181645
1470069
6256052
5833067
6288785
3707357
1414093
3347945
1358111
1754489
4503096
3424305
2233038
4817376
3941735
>>> for _ in range(10):
... print(s.pop())
...
4181645
6288785
1358111
1543072
3424305
6256052
4503096
5381194
1414093
2233038
It's a Python implementation detail and you should not rely on it.
As recommended in the comments, please see this answer
add a comment |
It doesn't occur if the numbers are higher
>>> l=list(range(655360, 6553600))
>>> for _ in range(20):
... el = ra.choice(l)
... s.add(el)
... print(el)
...
3589721
2762448
1543072
4489208
5381194
4181645
1470069
6256052
5833067
6288785
3707357
1414093
3347945
1358111
1754489
4503096
3424305
2233038
4817376
3941735
>>> for _ in range(10):
... print(s.pop())
...
4181645
6288785
1358111
1543072
3424305
6256052
4503096
5381194
1414093
2233038
It's a Python implementation detail and you should not rely on it.
As recommended in the comments, please see this answer
It doesn't occur if the numbers are higher
>>> l=list(range(655360, 6553600))
>>> for _ in range(20):
... el = ra.choice(l)
... s.add(el)
... print(el)
...
3589721
2762448
1543072
4489208
5381194
4181645
1470069
6256052
5833067
6288785
3707357
1414093
3347945
1358111
1754489
4503096
3424305
2233038
4817376
3941735
>>> for _ in range(10):
... print(s.pop())
...
4181645
6288785
1358111
1543072
3424305
6256052
4503096
5381194
1414093
2233038
It's a Python implementation detail and you should not rely on it.
As recommended in the comments, please see this answer
edited Nov 14 '18 at 14:49
answered Nov 14 '18 at 14:17
PynchiaPynchia
6,66232131
6,66232131
add a comment |
add a comment |
I have found a similar question in this topic, it could help you stackoverflow.com/questions/1867861/…
– Baptiste Gavalda
Nov 14 '18 at 14:22
1
See stackoverflow.com/questions/21017188/set-pop-isnt-random
– B. M.
Nov 14 '18 at 14:34