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
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
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,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,20,30,40] | |
def leftrotate(l): | |
s = 1 | |
e = len(l) - 1 | |
temp = l[0] | |
print(l[e]) | |
while s < len(l): | |
print(s) | |
l[s-1] =l[s] |
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
public class FizzBuzz { | |
public static void main(String [] args){ | |
Scanner scanner = new Scanner(System.in); | |
System.out.println("Number"); | |
int Number = scanner.nextInt(); | |
if(Number%3==0 && Number%5==0) | |
System.out.println("FIZZBUZZ"); | |
else if(Number%5==0) |
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 ")) | |
if (number%3 ==0 and number%5 ==0): | |
print("FizzBuzz") | |
elif(number%3 ==0): | |
print("Buzz") | |
elif(number%5 ==0): | |
print("Fizz") | |
else: | |
print(number) |
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
public class StarPyramid | |
{ | |
public static void Main(String[] args) | |
{ | |
Console.WriteLine("Triangle : "); | |
int n = 5; | |
for (int i = 1; i <= 5; i++) | |
{ | |
for (int j = 1; j <= (n - i); j++) | |
{ |
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
public class RightAngleTriangle | |
{ | |
public static void Main(String[] args) | |
{ | |
Console.WriteLine("Right angle triangle : "); | |
int n = 5; | |
for (int i = 1; i <= 5; i++) | |
{ | |
for (int j = 1; j <= i; j++) | |
{ |