Lec 5-7
Lec 5-7
Lecture 5
Tuples
def func_b(y):
print('inside func_b')
return y
def func_c(z):
print('inside func_c')
return z()
print(func_a())
print(5+func_b(2))
print(func_c(func_a))
print(sum_elem_method1([1,2,3,4]))
print(sum_elem_method2([1,2,3,4]))
L1.extend([0,6])
L=[9,6,0,3]
print(sorted(L))
L.sort()
L.reverse()
L1 = [1, 2, 3, 4] L1 = [1, 2, 3, 4]
L2 = [1, 2, 5, 6] L2 = [1, 2, 5, 6]
remove_dups(L1, L2) remove_dups_new(L1, L2)
print(L1, L2) print(L1, L2)
L1 = [1, 2, 3, 4]
L1 = [1, 2, 3, 4] L2 = [1, 2, 5, 6]
L2 = [1, 2, 5, 6] remove_dups_new(L1, L2)
remove_dups(L1, L2) print(L1, L2)
print(L1, L2)
n=3
TowerOfHanoi(n, 'A', 'C', 'B')
# A, C, B are the name of poles
if x == 0 or x == 1:
return 1
else:
return fib(x-1) + fib(x-2)
def toChars(s):
s = s.lower()
ans = ''
for c in s:
if c in 'abcdefghijklmnopqrstuvwxyz':
ans = ans + c
return ans
def isPal(s):
if len(s) <= 1:
return True
else:
return s[0] == s[-1] and isPal(s[1:-1])
return isPal(toChars(s))
#print(isPalindrome('eve'))
#print(isPalindrome('Able was I, ere I saw Elba'))
#print(isPalindrome('Is this a palindrome'))
beatles = lyrics_to_frequencies(she_loves_you)
print(beatles)
#print(words_often(beatles, 5))
d = {1:1, 2:2}
argToUse = 34
#print("")
#print('using fib')
#print(fib(argToUse))
#print("")
#print('using fib_efficient')
#print(fib_efficient(argToUse, d))