+ 1
Please help.. Python -sets UNION , INTErsection difference symmetric-difference
Create two sets 'a', and 'b' with following values. a = ('10','20','30','40') b = ('30','60') Determine the following Union; store the output in variable 'u' and print it. Intersection; store the output in variable 'i' and print it. Difference between set 'a' and 'b'; store the output in variable 'd' and print it. Symmetric difference; store the output in variable 'sd' and print it.
3 Antworten
0
union (a|b)
intersect (a&b)
difference (a-b)
symmetric difference (a^b)
Here's example:
https://code.sololearn.com/cGsa5tefN04u/?ref=app
0
thanks dude
0
a = {1,2,3,4,5}
b = {4,5,6,7,8}
u = (a|b)
print(f"La Union es : {u}")
i = (a&b)
print(f"La Interseccion es : {i}")
d = (a^b)
print(f"La Dif. Simetrica es : {d}")
a_s = (a-b)
print(f"La Diferencia es : {a_s}")
La palabra "as" no lo acepta como nombre de variable. Coloqué a_s
Espero haber ayudado