Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
PySetUnpack
#Python 2.7.17 #PySetUnpack: Python set comprehension,symmetric difference() and unpacking tuple #this code is created by Rezaul Hoque on December 27,2021;contact: jewelmrh@yahoo.com,Dhaka, Bangladesh #note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; #unpacking tuple left = 10 right = 11 print "left= ",left print" right= ",right left,right = right,left print "left= ",left print" right= ",right fruit={'Guava','Orange','Mango'} vegetable={'Bottle gourd','Cucumber','Carrot'} #Symmetric_difference() and " ^" operator s1={1,2,3} s2={4,5,6} p=[7,8,9] s=s1.symmetric_difference(s2) s5=s1.symmetric_difference(p) s3=s1^s2 #s4=s1^p print(s) print(s3) #print(s4) print(s5) #set comprehension lowFruit={item.lower() for item in fruit if item != 'Mango'} lowFruit2=set(map(lambda item: item.lower(),fruit)) print(lowFruit) print(lowFruit2)
run
|
edit
|
history
|
help
0
PyClassInit
binary
PyEnum
My Temp Converter
Printing
Problem: Binary
Counter() in collections
Parity in Python
building a basic calculator
on_off