{{ message }}

Instantly share code, notes, and snippets.

🎯
Focusing

# KAPIL MATHUR bondnotanymore

🎯
Focusing
Created Oct 22, 2017
View Alphabet to position of alphabet
 def alphabet_position(text_string): dict1 = {value: (int(key) + 1) for key, value in enumerate(list(string.ascii_lowercase))} return " ".join([str(dict1[alp]) for alp in list(text_string.lower()) if alp.isalpha()]) print alphabet_position("The sunset sets at twelve o' clock.") Output : "20 8 5 19 21 14 19 5 20 19 5 20 19 1 20 20 23 5 12 22 5 15 3 12 15 3 11"
Created Oct 21, 2017
View Combinations
 from itertools import combinations nums2 = [-25,-10,-7,-3,2,4,8,10] def sum_of_3_0(list1, sum1): print "List of possible combinations : {}".format([list(comb) for comb in combinations(list1, 3) if sum(comb) == sum1]) sum_of_3_0(nums2, 0)
Last active Oct 20, 2017
View Power of 3 or not
 import sys def if_powerof(n,x): var = n power = 0 if n%x == 0: while var > 1: if var % x == 0:
Created Oct 19, 2017
View Max_of_3
 def max_of_three(a,b,c): if a > b: if a > c: return "The largest of 3 nos is : {}".format(a) else: return "The largest of 3 nos is : {}".format(c) else: if b > c: return "The largest of 3 nos is : {}".format(b) else:
Created Oct 19, 2017
View gist:b58ba43fbb0f1b30ece3ebca8b6126ae
 a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] a = list(set(a)) b = list(set(b)) def common_element(): return [x for x in a for y in b if x == y] print common_element()