1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Mar 16 17:08:52 2018 @author: beast """ def version1(): a=['a','b','c','d','e'] # list 1 b=['a','b','c','d','e','f','g','h'] # list 2 c=[k for k in (a)if (k in (a) and k not in (b))] # include unique item from list 1 : items are (list1-list2)(set thoery) d=[l for l in (b) if l in (a ) and l in (b) or (l not in (a) and l in (b))] #include all the comman from list 1 and unique from list 2 lst=c+d # append above two comprehensed list to get union of list1 U list2 lst.sort() # not neccessay but makes list easy to understand (sorting in ascending order ) print("\n\na=",a) print("\n\nb=",b) print("\n\nunion=",lst) return lst # make it easy to import and use e.g import union_beast.py and then call union_beast.version1() it will return this union of list def version2(): a=['a','b','c','d','e'] # list 1 b=['d','e','f','g','h'] # list 2 c=[] for k in range (max(len(a),len(b))):# max return maximum number among two or more number so we iterate over max of length of both the list if k <len(a) and a[k] not in (b) : # if length of a is greater than current indexing and element at kth index is not present in list b (ie get List1-list 2 item) c.append(a[k]) # if item is unique to list 1 then append to result list (here c) if k <len(b) and b[k] not in (a) :# same as above logic but here we get item unique to list 2 (here list b) c.append(b[k]) # same append to result list (here c) if k <len(b) and b[k] in (a) : # now add the comman item to list (this is vital step as we only add only one instance of item that are both present in list 1 and list 2) eg if 2 is present in list 1 and list 2 we add only one 2 to result list c.append(b[k]) # append to result list (here c) c.sort() # not neccessary but make the result more eye catchy print("\n\na=",a) #print list 1 print("\n\nb=",b)#print list 2 print("\n\nunion=",c) #print the result if __name__=="__main__": # used to run the function via main loading ...i.e if the module is not imported print("\n----------by version 1------------\n") version1() print("\n\n------------by version 2------------") version2() |
Adsense is used by majority of expert bloggers for their website monetization because it is a cookie based contextual advertising system that shows targeted ads relevant to the content and reader. As bloggers are paid on per click basis, they try various ad placements on the blog to increase the revenue and get maximum clicks on the ad units. Well, on some blogs, you might have seen Adsense ad units placed below the post title. Do you know why? It is because the area just below the post title gets the most exposure and is the best place to put AdSense ad units to increase Click Through Rate (CTR). Even though ads below post title work like a charm but this doesn’t mean that it will work for you as well. If you want to find out the best AdSense ads placement for your blog, try experimenting by placing ads at various locations such as header, sidebar, footer, etc. You can try other blog monetization methods as well to effectively monetize y...
Comments
Post a Comment
share your thoughts ....