Skip to content

Instantly share code, notes, and snippets.

View bondnotanymore's full-sized avatar
🎯
Focusing

KAPIL MATHUR bondnotanymore

🎯
Focusing
View GitHub Profile
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()
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:
import sys
def if_powerof(n,x):
var = n
power = 0
if n%x == 0:
while var > 1:
if var % x == 0:
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)
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"