This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
l=[10,5,28,6,35,29] | |
def getSeclargest(l): | |
if len(l)<= 1: | |
return None | |
lar=l[0] | |
slar = None | |
for x in l[1:]: | |
if x > lar: | |
slar =lar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
l=[10,5,28,6,35] | |
def getmax(l): | |
if not l: | |
return None | |
else: | |
res =l[0] | |
for i in range(1,len(l)): | |
if l[i] > res: | |
res =l[i] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
l=[10,5,28,6,35] | |
def getmax(l): | |
for i in l: | |
for j in l: | |
if j > i: | |
break | |
else: | |
return i | |
return None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def decToBinary(n): | |
if n==0: | |
return "0" | |
res ="" | |
while n > 0: | |
res = res + str(n%2) | |
n = n//2 | |
return res[::-1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a =int(input("Enter your number \n")) | |
b =int(input("Enter your number \n")) | |
small = min(a,b) | |
for i in range(1,small+1): | |
if (a%i ==0 and b% i ==0): | |
gcd =i | |
print(gcd) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = int(input("Enter your number \n")) | |
b = int(input("Enter your number \n")) | |
res = max(a, b) | |
while res <= a * b: | |
if res % a == 0 and res % b == 0: | |
break | |
res += 1 | |
print(res) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = int(input("Enter your number")) | |
for i in range(n): | |
for j in range(n): | |
print('*',end="") | |
print() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
number = int(input("Enter your number \n")) | |
for i in range(2, number + 1): | |
if number % i == 0: | |
print(i, "is smallest divisor") | |
break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
number = int(input()) | |
counter =0 | |
while number > 0: | |
number = number//10 | |
print(number) | |
counter +=1 | |
print("number of digits :",counter) |