Solution
def multi_sum(n1, n2):
pro = n1 *n2
if(pro < 500):
return pro
else:
return n1 +n2
number1 = int(input("Enter first number "))
number2 = int(input("Enter second "))
result = multi_sum(number1, number2)
print(result)
def fun(x):
prevNum=0
for i in range(x):
tot = prevNum + i
print(tot)
prevNum = i
print("cummulative addition in a given range")
fun(10)
Str1 = input("Enter String ")
print("Original String is ", Str1)
print("chars at even pos :")
for i in range(0, len(Str1)-1, 2):
print("index[",i,"]", Str1[i] )
def remCharFun(str, n):
return str[n:]
print("Remaining string")
print(remCharFun("dzonejpr", 4))
def checkForSame(myList):
p = myList[0]
q = myList[-1]
if(p == q):
return True
else:
return False
test = [20, 30, 40, 50, 20]
print("result :", checkForSame(test))
def DivByThree(TempList):
for n in TempList:
if (n % 3 == 0):
print(n)
Lst = [15, 25, 33, 70, 88]
print("Finding divisible of 3 in a list")
DivByThree(Lst)
def count_Dzone(statement):
count = 0
for i in range(len(statement)-1):
count += statement[i:i+5] == 'Dzone'
return count
count = count_Dzone(""Dzone is an IT Company.Dzone provide Python and Machine Learning Course in Jaipur"")
print("Dzone appeared ", count, "times")
def revCheck(number):
originalNum = number
reverseNum=0
while(number > 0):
reminder = number % 10
reverseNum = (reverseNum *10) + reminder
number = number // 10
if(originalNum == reverseNum):
return True
else:
return False
print("Is orig. and rev. number is same")
print(revCheck(141)
def CustList(L1, L2):
L3 = []
for a in L1:
if(a % 2 != 0):
L3.append(a)
for b in L2:
if(b % 2 == 0):
L3.append(b)
return L3
print("Ans: \n")
L1 = [10, 20, 23, 11, 17]
L2 = [13, 43, 24, 36, 12]
print(CustList(L1, L2))