Write the program to remove empty tuples from a list
def Remove(tuples):
tuples = filter(None, tuples)
return tuples
Write a python program to find Cumulative sum of a list
list=[10,20,30,40,50]
new_list=[]
j=0
for i in range(0,len(list)):
j+=list[i]
new_list.append(j)
print(new_list)
Write a python function to convert a list to string
s = ['I', 'want', 4, 'apples', 'and', 18, 'bananas']
listToStr = ' '.join(map(str, s))
print(listToStr)
Write a python program to merge 2 dictionaries
x = {'a' : 1, 'b' : 2, 'c' : 3}
y = {'x' : 10, 'y' : 20, 'z' : 30 }
z = {**x , **y}
Write a python code to implement Sigmoid function
import math
def sigmoid(x):
return 1 / (1 + math.exp(-x))
Write a python code to implement RELU function
def relu(array):
return [max(0,i) for i in array if(isinstance(i, int) or isinstance(i, float))]
Write a python function to check whether the given number is fibonacci or not
def fiboacci_number_check(n):
if(isinstance(n,int)):
result = list(filter(lambda num : int(math.sqrt(num)) * int(math.sqrt(num)) == num, [5*n*n + 4,5*n*n - 4] ))
return bool(result)
else:
raise TypeError("Input should be of type Int")
Write a python program to strip all the vowels in a string
string = "Remove Vowel"
vowel = ['a', 'e', 'i', 'o', 'u']
"".join([i for i in string if i not in vowel]
Write a python program to give the next fibonacci number
num_1, num_2,count = 0, 1,0
def next_fibbonacci_number() :
nonlocal num_1, num_2, count
if(count == 0):
count+=1
return 0
elif(count==1):
count+=1
return num_2
else:
num_1, num_2 = num_2, num_1+num_2
return num_2
return next_fibbonacci_number
Write a python function to calculate factorial of a given number
def factorial(n):
fact = 1
for num in range(2, n + 1):
fact = fact * num
return(fact)
Write a python program which will find all such numbers which are divisible by 7 but are not a multiple of 5 ;between 2000 and 3200 (both included)
l=[]
for i in range(2000, 3201):
if (i%7==0) and (i%5!=0):
l.append(str(i))
print(','.join(l))