+ 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.

6th Mar 2018, 2:38 PM
Sashank Reddy
Sashank Reddy - avatar
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
6th Mar 2018, 2:57 PM
Sylar
0
thanks dude
25th Mar 2018, 7:14 PM
Sashank Reddy
Sashank Reddy - avatar
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
28th Mar 2018, 11:55 AM
Luis Gonzalez
Luis Gonzalez - avatar