Cordiales Saludos <center>  </center> #### Operaciones con conjuntos Para trabajar las operaciones con conjuntos utilizaremos los conjuntos * conjunto_1 = {1, 2, 3, 4} * conjunto_2 = {10, 3, 4, 20} Comencemos declarando los dos conjuntos ~~~ >>> conjunto_1 = set(range(1,5)) >>> conjunto_1 {1, 2, 3, 4} >>> conjunto_2 = set([4, 3, 10, 20]) >>> conjunto_2 {10, 3, 4, 20} ~~~ ## Unión La unión de dos conjunto nos dará un nuevo conjunto con los elementos de ambos conjuntos. En el siguiente ejercicio el conjunto_u contendrá los elementos del conjunto_1 y los elementos del conjunto_2. En esta oportunidad utilizamos el método **.union** ~~~ >>> conjunto_1 {1, 2, 3, 4} >>> conjunto_2 {10, 3, 4, 20} ~~~ ~~~ >>> conjunto_u = conjunto_1.union(conjunto_2) >>> conjunto_u {1, 2, 3, 4, 10, 20} ~~~ Otra forma de resolver el ejercicio. (Usando el operador | ) ~~~ >>> conjunto_u2 = conjunto_1 | conjunto_2 >>> conjunto_u2 {1, 2, 3, 4, 10, 20} ~~~ ## Intersección La intersección de dos conjunto nos dará un nuevo conjunto con los elementos comunes. En el siguiente ejercicio el conjunto_i contendrá los elementos del conjunto_1 que estén en el conjunto_2. En esta oportunidad utilizamos el método .intersection ~~~ >>> conjunto_1 {1, 2, 3, 4} >>> conjunto_2 {10, 3, 4, 20} ~~~ ~~~ >>> conjunto_i = conjunto_1.intersection(conjunto_2) >>> conjunto_i {3, 4} ~~~ Otra forma de resolver el ejercicio. (Usando el operador & ) ~~~ >>> conjunto_i2 = conjunto_1 & conjunto_2 >>> conjunto_i2 {3, 4} ~~~ ## Diferencia La diferencia de dos conjunto nos dará un nuevo conjunto con los elementos del primer conjunto que no pertenezcan al segundo conjunto. En el siguiente ejercicio el conjunto_d contendrá los elementos del conjunto_1 que no pertenecen al conjunto_2. En esta oportunidad utilizamos el método .difference ~~~ >>> conjunto_1 {1, 2, 3, 4} >>> conjunto_2 {10, 3, 4, 20} ~~~ ~~~ >>> conjunto_d = conjunto_1.difference(conjunto_2) >>> conjunto_d {1, 2} ~~~ Otra forma de resolver el ejercicio. (Usando el operador - ) ~~~ >>> conjunto_d2 = conjunto_1 - conjunto_2 >>> conjunto_d2 {1, 2} ~~~ ## Diferencia Simétrica La diferencia Simétrica de dos conjunto nos dará un nuevo conjunto con los elementos que no son comunes. En el siguiente ejercicio el conjunto_d_s contendrá los elementos que no son comunes en el conjunto_1 y en el conjunto_2. En esta oportunidad utilizamos el método .symmetric_difference ~~~ >>> conjunto_1 {1, 2, 3, 4} >>> conjunto_2 {10, 3, 4, 20} ~~~ ~~~ >>> conjunto_d_s = conjunto_1.symmetric_difference(conjunto_2) >>> conjunto_d_s {1, 2, 10, 20} ~~~ Otra forma de resolver el ejercicio. (Usando el operador ^ ) ~~~ >>> conjunto_d_s = conjunto_1 ^ conjunto_2 >>> conjunto_d_s {1, 2, 10, 20} ~~~ ## Determinar si un elemento pertenece a un conjunto ~~~ >>> conjunto_1 {1, 2, 3, 4} >>> 5 in conjunto_1 False >>> 1 in conjunto_1 True >>> ~~~ ## Determinar el número de elementos de un conjunto ~~~ >>> conjunto_1 {1, 2, 3, 4} >>> elementos = len(conjunto_1) >>> elementos 4 >>> ~~~ --- Hasta aquí la continuación de la publicación pasada: [Curso Intermedio de Python N03 Conjuntos](https://peakd.com/hive-154226/@rafaelaquino/curso-intermedio-de-python-n03-conjuntos) ### Profundizando en python ##### Usando el guión bajo _ ~~~ >>> a = 10 >>> a 10 >>> _ 10 >>> >>> b = 100 >>> _ 10 ~~~ ~~~ >>> a = 10 >>> a 10 >>> b = 100 >>> b 100 >>> _ 100 >>> ~~~ ~~~ >>> a,b,c,d,_ = 1,2,3,4,5 >>> _ 5 ~~~ ~~~ >>> lista = [10,9,8,7] >>> for _ in lista: ... print(_) ... 10 9 8 7 >>> ~~~ ~~~ >>> lista2 [1, 2, 3] >>> for _ in lista2: ... print('Son tres impresiones') ... Son tres impresiones Son tres impresiones Son tres impresiones >>> ~~~ ~~~ >>> a,_,c = 1,2,3 >>> _ 2 >>> _ * 3 6 >>> ~~~ ##### Recurso para aprender Python [Curso Gratis de Programación](https://siraquino.github.io/pythoncumanes/) [Curso de Programación Básica](https://siraquino.github.io/pythoncumanes/programacionbasica.html) [Mi Twitter](https://twitter.com/Rafa_elaquino) [Mi facebook](https://www.facebook.com/rafael.aquino.5815)
author | rafaelaquino |
---|---|
permlink | curso-intermedio-de-python-n04-conjuntos-continuacion |
category | hive-154226 |
json_metadata | {"app":"peakd/2023.7.1","format":"markdown","tags":["developspanish","stem-espanol","stemsocial","linux","python","original-content","developer","spanish","tecnologia","programador"],"users":["rafaelaquino"],"image":["https://files.peakd.com/file/peakd-hive/rafaelaquino/23uR9nP9MBWfzVtmpsHoGVUm4dmYjwcua8piDrU5roUTWYCL8ZL6SJA9oCQDHwGmFpaKv.png"]} |
created | 2023-07-24 22:10:27 |
last_update | 2023-07-24 22:10:27 |
depth | 0 |
children | 2 |
last_payout | 2023-07-31 22:10:27 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.858 HBD |
curator_payout_value | 0.819 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 4,218 |
author_reputation | 112,619,069,555,129 |
root_title | "Curso Intermedio de Python N04 Conjuntos (Continuación)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 125,611,185 |
net_rshares | 3,453,384,245,560 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
eric-boucher | 0 | 2,013,726,842 | 0.4% | ||
roelandp | 0 | 45,451,017,658 | 5% | ||
cloh76 | 0 | 525,587,477 | 0.4% | ||
stea90 | 0 | 916,667,612 | 1% | ||
akipponn | 0 | 670,083,065 | 5% | ||
avellana | 0 | 60,057,778,262 | 56% | ||
lordvader | 0 | 6,386,531,884 | 0.8% | ||
rmach | 0 | 2,953,713,950 | 5% | ||
lemouth | 0 | 291,182,512,284 | 10% | ||
lamouthe | 0 | 728,538,483 | 10% | ||
tfeldman | 0 | 732,118,440 | 0.4% | ||
metabs | 0 | 1,035,131,556 | 10% | ||
mcsvi | 0 | 138,042,202,972 | 50% | ||
cnfund | 0 | 1,520,138,170 | 0.8% | ||
justyy | 0 | 4,619,375,069 | 0.8% | ||
curie | 0 | 62,646,482,957 | 0.8% | ||
techslut | 0 | 23,868,078,049 | 4% | ||
steemstem | 0 | 178,861,463,579 | 10% | ||
edb | 0 | 947,426,578 | 1% | ||
walterjay | 0 | 62,407,307,426 | 5% | ||
valth | 0 | 1,598,432,297 | 5% | ||
metroair | 0 | 3,440,660,515 | 0.8% | ||
dna-replication | 0 | 338,696,682 | 10% | ||
privex | 0 | 928,102,441 | 0.8% | ||
dhimmel | 0 | 50,799,071,950 | 2.5% | ||
detlev | 0 | 3,321,722,814 | 0.24% | ||
federacion45 | 0 | 1,156,585,937 | 0.4% | ||
iansart | 0 | 1,511,805,014 | 0.4% | ||
mobbs | 0 | 16,151,765,401 | 5% | ||
eliel | 0 | 1,853,261,476 | 0.8% | ||
jerrybanfield | 0 | 2,698,354,830 | 0.8% | ||
rt395 | 0 | 1,920,606,539 | 1.5% | ||
bitrocker2020 | 0 | 1,485,806,055 | 0.12% | ||
sustainablyyours | 0 | 4,177,302,022 | 5% | ||
arunava | 0 | 3,254,469,658 | 0.32% | ||
samminator | 0 | 7,162,045,475 | 5% | ||
enjar | 0 | 5,725,580,587 | 0.72% | ||
lorenzor | 0 | 1,343,271,793 | 50% | ||
alexander.alexis | 0 | 5,781,317,260 | 10% | ||
jayna | 0 | 1,032,054,652 | 0.16% | ||
princessmewmew | 0 | 1,071,457,246 | 0.4% | ||
joeyarnoldvn | 0 | 480,103,538 | 1.47% | ||
gunthertopp | 0 | 10,520,660,839 | 0.2% | ||
empath | 0 | 545,342,758 | 0.4% | ||
minnowbooster | 0 | 1,039,112,884,557 | 20% | ||
felt.buzz | 0 | 1,828,561,147 | 0.2% | ||
tsoldovieri | 0 | 995,308,392 | 5% | ||
steemwizards | 0 | 531,715,116 | 0.8% | ||
neumannsalva | 0 | 615,819,928 | 0.4% | ||
stayoutoftherz | 0 | 21,010,025,838 | 0.2% | ||
abigail-dantes | 0 | 3,566,913,659 | 10% | ||
zonguin | 0 | 488,084,675 | 2.5% | ||
investingpennies | 0 | 2,932,835,844 | 0.8% | ||
iamphysical | 0 | 825,677,335 | 90% | ||
zyx066 | 0 | 776,580,628 | 0.24% | ||
revo | 0 | 1,497,470,427 | 0.8% | ||
azulear | 0 | 1,426,351,628 | 100% | ||
djlethalskillz | 0 | 1,567,659,624 | 5% | ||
psicoluigi | 0 | 803,488,831 | 50% | ||
rocky1 | 0 | 118,288,058,937 | 0.12% | ||
thelordsharvest | 0 | 683,595,864 | 0.8% | ||
sumant | 0 | 1,847,712,674 | 0.4% | ||
meno | 0 | 3,472,785,377 | 0.4% | ||
doifeellucky | 0 | 2,149,701,970 | 0.4% | ||
enzor | 0 | 589,304,507 | 10% | ||
bartosz546 | 0 | 607,730,079 | 0.4% | ||
sunsea | 0 | 615,884,103 | 0.4% | ||
bluefinstudios | 0 | 529,474,223 | 0.24% | ||
steveconnor | 0 | 630,272,675 | 0.4% | ||
sandracarrascal | 0 | 503,083,378 | 50% | ||
kenadis | 0 | 2,550,885,445 | 10% | ||
amaponian | 0 | 1,461,495,306 | 100% | ||
madridbg | 0 | 3,775,671,978 | 10% | ||
punchline | 0 | 2,215,188,301 | 0.8% | ||
r00sj3 | 0 | 1,864,119,095 | 0.4% | ||
sco | 0 | 2,733,133,409 | 10% | ||
ennyta | 0 | 983,963,154 | 50% | ||
abeba | 0 | 2,091,931,381 | 35% | ||
ydavgonzalez | 0 | 2,535,843,988 | 10% | ||
intrepidphotos | 0 | 2,285,408,436 | 7.5% | ||
fineartnow | 0 | 522,935,208 | 0.4% | ||
fragmentarion | 0 | 2,582,831,886 | 10% | ||
utube | 0 | 643,796,379 | 0.8% | ||
dynamicrypto | 0 | 2,936,787,573 | 1% | ||
neneandy | 0 | 877,139,011 | 0.8% | ||
sportscontest | 0 | 806,454,465 | 0.8% | ||
pandasquad | 0 | 1,733,078,112 | 0.8% | ||
miguelangel2801 | 0 | 788,725,042 | 50% | ||
fantasycrypto | 0 | 640,307,395 | 0.8% | ||
franciscomarval | 0 | 949,296,940 | 100% | ||
emiliomoron | 0 | 1,418,967,965 | 5% | ||
photohunt | 0 | 515,805,144 | 0.8% | ||
geopolis | 0 | 608,555,361 | 10% | ||
robertbira | 0 | 1,033,841,277 | 2.5% | ||
alexdory | 0 | 1,623,619,371 | 10% | ||
irgendwo | 0 | 2,573,517,965 | 0.8% | ||
cyprianj | 0 | 11,485,125,352 | 10% | ||
melvin7 | 0 | 6,655,116,837 | 5% | ||
francostem | 0 | 1,313,886,922 | 10% | ||
endopediatria | 0 | 693,112,961 | 20% | ||
omarmontes | 0 | 52,907,807,607 | 90% | ||
andresromero | 0 | 3,224,770,943 | 90% | ||
croctopus | 0 | 1,472,357,954 | 100% | ||
cryptictruth | 0 | 2,297,516,995 | 0.5% | ||
amigoponc | 0 | 6,278,381,565 | 100% | ||
superlotto | 0 | 2,344,512,767 | 0.8% | ||
emperatriz1503 | 0 | 15,732,650,705 | 70% | ||
movingman | 0 | 497,468,776 | 20% | ||
tomastonyperez | 0 | 16,953,783,701 | 50% | ||
elvigia | 0 | 10,959,522,967 | 50% | ||
sanderjansenart | 0 | 683,965,465 | 0.4% | ||
manniman | 0 | 45,513,528,293 | 11% | ||
qberry | 0 | 507,803,052 | 0.4% | ||
juanmanuellopez1 | 0 | 2,138,977,531 | 56% | ||
braaiboy | 0 | 1,455,077,788 | 0.4% | ||
therising | 0 | 14,137,337,535 | 0.8% | ||
felixmarranz | 0 | 41,606,091,230 | 100% | ||
de-stem | 0 | 5,337,111,222 | 9.9% | ||
marijo-rm | 0 | 75,960,533,942 | 70% | ||
josedelacruz | 0 | 4,752,386,320 | 50% | ||
oscurity | 0 | 594,223,403 | 7% | ||
erickyoussif | 0 | 724,831,367 | 100% | ||
deholt | 0 | 529,140,394 | 8.5% | ||
diabonua | 0 | 720,096,320 | 0.4% | ||
temitayo-pelumi | 0 | 851,484,891 | 10% | ||
andrick | 0 | 857,557,921 | 50% | ||
doctor-cog-diss | 0 | 8,043,112,921 | 10% | ||
uche-nna | 0 | 871,526,085 | 0.64% | ||
cheese4ead | 0 | 638,226,115 | 0.4% | ||
mafufuma | 0 | 7,443,468,329 | 1% | ||
nattybongo | 0 | 5,380,414,947 | 10% | ||
radiosteemit | 0 | 11,933,815,268 | 70% | ||
bflanagin | 0 | 997,118,130 | 0.4% | ||
ubaldonet | 0 | 1,591,278,719 | 80% | ||
armandosodano | 0 | 1,751,976,996 | 0.4% | ||
yourmind | 0 | 15,145,815,878 | 100% | ||
goblinknackers | 0 | 71,871,195,785 | 7% | ||
kylealex | 0 | 4,540,298,482 | 10% | ||
fran.frey | 0 | 4,173,461,364 | 50% | ||
thelittlebank | 0 | 2,763,774,172 | 0.4% | ||
pboulet | 0 | 24,014,817,143 | 8% | ||
stem-espanol | 0 | 21,030,783,994 | 100% | ||
cliffagreen | 0 | 4,699,785,049 | 10% | ||
aleestra | 0 | 12,719,718,801 | 80% | ||
lagitana | 0 | 2,732,509,195 | 56% | ||
naty16 | 0 | 7,227,620,725 | 14% | ||
brianoflondon | 0 | 10,613,727,375 | 0.2% | ||
giulyfarci52 | 0 | 1,705,933,359 | 50% | ||
steemcryptosicko | 0 | 1,412,929,534 | 0.16% | ||
cakemonster | 0 | 502,153,136 | 0.8% | ||
stem.witness | 0 | 544,148,552 | 10% | ||
steemstorage | 0 | 962,274,737 | 0.8% | ||
aqua.nano | 0 | 496,502,028 | 100% | ||
crowdwitness | 0 | 12,523,689,170 | 5% | ||
apokruphos | 0 | 11,695,153,115 | 2% | ||
steemean | 0 | 9,967,802,789 | 5% | ||
cryptofiloz | 0 | 1,238,248,787 | 0.8% | ||
lmvc | 0 | 1,028,699,618 | 44.8% | ||
zeruxanime | 0 | 1,704,966,404 | 5% | ||
lfu-radio | 0 | 622,254,080 | 35% | ||
lmvc-spaco | 0 | 558,892,432 | 44.8% | ||
andresrk | 0 | 502,412,987 | 33.6% | ||
steemstem-trig | 0 | 160,651,429 | 10% | ||
baltai | 0 | 805,335,477 | 0.4% | ||
atheistrepublic | 0 | 835,653,382 | 0.4% | ||
ibt-survival | 0 | 35,872,984,308 | 10% | ||
nanyuris | 0 | 7,119,099,337 | 100% | ||
lightpaintershub | 0 | 661,912,143 | 1% | ||
radiohive | 0 | 22,367,783,784 | 70% | ||
stemsocial | 0 | 79,660,849,895 | 10% | ||
globalcurrencies | 0 | 3,828,198,211 | 100% | ||
hiveonboard | 0 | 633,856,777 | 0.4% | ||
louis00334 | 0 | 2,141,186,307 | 50% | ||
kvfm | 0 | 1,488,118,222 | 35% | ||
noelyss | 0 | 3,720,015,787 | 5% | ||
laradio | 0 | 3,328,338,974 | 70% | ||
mercmarg | 0 | 5,909,774,242 | 28% | ||
carmenm20 | 0 | 2,162,225,314 | 70% | ||
aabcent | 0 | 1,759,746,418 | 0.64% | ||
cleydimar2000 | 0 | 6,100,640,904 | 35% | ||
radiolovers | 0 | 14,356,155,870 | 70% | ||
ciresophen | 0 | 12,476,972,470 | 100% | ||
alberto0607 | 0 | 1,856,321,958 | 70% | ||
darlingomaet1 | 0 | 863,098,521 | 70% | ||
junydoble | 0 | 1,263,499,210 | 49% | ||
victor816 | 0 | 704,259,625 | 70% | ||
meritocracy | 0 | 8,959,106,976 | 0.08% | ||
jmsansan | 0 | 580,620,964 | 0.4% | ||
bea23 | 0 | 19,218,556,410 | 70% | ||
dcrops | 0 | 5,521,572,769 | 0.4% | ||
ciudadcreativa | 0 | 2,639,569,393 | 56% | ||
traderhive | 0 | 1,784,393,535 | 0.8% | ||
mayorkeys | 0 | 19,381,016,835 | 30% | ||
edinson001 | 0 | 739,214,156 | 70% | ||
nfttunz | 0 | 1,165,639,946 | 0.08% | ||
helencct | 0 | 1,277,967,825 | 70% | ||
podping | 0 | 1,098,997,788 | 0.2% | ||
fabianar25 | 0 | 697,482,080 | 35% | ||
ronymaffi | 0 | 1,820,033,652 | 70% | ||
shakavon | 0 | 481,936,900 | 35% | ||
seinkalar | 0 | 1,126,223,486 | 0.8% | ||
aries90 | 0 | 6,467,119,497 | 0.8% | ||
hyun-soo | 0 | 2,595,536,118 | 50% | ||
buiitre | 0 | 6,293,357,074 | 100% | ||
yixn | 0 | 7,472,959,278 | 0.4% | ||
crypt0gnome | 0 | 583,771,721 | 0.16% | ||
susurrodmisterio | 0 | 6,846,159,704 | 35% | ||
checkyzk | 0 | 22,375,745,779 | 98% | ||
deadleaf | 0 | 3,961,899,261 | 100% | ||
plicc8 | 0 | 912,693,492 | 10% | ||
visualblock | 0 | 254,905,319,986 | 70% | ||
sieghard1990 | 0 | 2,379,110,489 | 100% | ||
sbtofficial | 0 | 635,620,997 | 0.4% | ||
nahuelgameplays | 0 | 844,590,737 | 35% | ||
reverio | 0 | 1,190,040,125 | 5% |
<div class='text-justify'> <div class='pull-left'> <img src='https://stem.openhive.network/images/stemsocialsupport7.png'> </div> Thanks for your contribution to the <a href='/trending/hive-196387'>STEMsocial community</a>. Feel free to join us on <a href='https://discord.gg/9c7pKVD'>discord</a> to get to know the rest of us! Please consider delegating to the @stemsocial account (85% of the curation rewards are returned). You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support. <br /> <br /> </div>
author | stemsocial |
---|---|
permlink | re-rafaelaquino-curso-intermedio-de-python-n04-conjuntos-continuacion-20230727t152418092z |
category | hive-154226 |
json_metadata | {"app":"STEMsocial"} |
created | 2023-07-27 15:24:18 |
last_update | 2023-07-27 15:24:18 |
depth | 1 |
children | 0 |
last_payout | 2023-08-03 15:24:18 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 565 |
author_reputation | 22,927,823,584,327 |
root_title | "Curso Intermedio de Python N04 Conjuntos (Continuación)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 125,692,528 |
net_rshares | 0 |
<center>  <sup> Has sido curado por @visualblock / You've been curated by @visualblock Bienvenidas delegaciones / Delegations welcome [Encuentra nuestra comunidad aquí / Find our community here](https://discord.gg/tGuctbfYKN) [Trail de Curación / Curation Trail](https://hive.vote/dash.php?trail=visualblock&i=1) [Vota por nuestro Testigo aliado - @hispapro](https://vote.hive.uno/@hispapro) / [Vote for our allied Witness - @hispapro](https://vote.hive.uno/@hispapro) [Más información sobre el testigo aquí](https://ecency.com/hive-111111/@hispapro/witness-announcement-descubre-el-nuevo) / [More information about the witness here](https://ecency.com/hive-111111/@hispapro/witness-announcement-descubre-el-nuevo) </sup> </center>
author | visualblock |
---|---|
permlink | re-rafaelaquino-2023724t22311930z |
category | hive-154226 |
json_metadata | {"tags":["developspanish","stem-espanol","stemsocial","linux","python","original-content","developer","spanish","tecnologia","programador"],"app":"ecency/3.0.35-vision","format":"markdown+html"} |
created | 2023-07-25 03:31:18 |
last_update | 2023-07-25 03:31:18 |
depth | 1 |
children | 0 |
last_payout | 2023-08-01 03:31:18 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 839 |
author_reputation | 152,737,702,239,424 |
root_title | "Curso Intermedio de Python N04 Conjuntos (Continuación)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 125,619,077 |
net_rshares | 0 |