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
| ## Read input as specified in the question. | |
| ## Print output as specified in the question. | |
| num=int(input()) | |
| count=1 | |
| for i in range(1,num+1): | |
| for j in range(0,i): | |
| print(i+j,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
| ## Read input as specified in the question. | |
| ## Print output as specified in the question. | |
| num=int(input()) | |
| count=num | |
| for i in range(1,num+1): | |
| while count>1: | |
| print(" ",end="") | |
| count=count-1 | |
| for j in range(0,i): | |
| print(i+j,end="") |
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
| ## Read input as specified in the question. | |
| ## Print output as specified in the question. | |
| num=int(input()) | |
| i=1 | |
| while num>=i: | |
| spaces=1 | |
| while spaces<=(num-i): | |
| print(" ",end="") | |
| spaces=spaces+1 | |
| k=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
| ## Read input as specified in the question. | |
| ## Print output as specified in the question. | |
| FibArray = [1, 1] | |
| def fibonacci(n): | |
| if n < 0: | |
| print("Incorrect input") | |
| elif n <= len(FibArray): | |
| return FibArray[n - 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=int(input()) | |
| p=2 #set the starting node | |
| prime = [True for i in range(l + 1)] #create a prime list and make all elements set to TRUE | |
| prime[0] = False | |
| prime[1] = False | |
| while p*p <=l: | |
| if prime[p]==True: | |
| for i in range(p*2,l+1,p): | |
| prime[i]=False |
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 printTable(start,end,step): | |
| #Implement Your Code Here | |
| while True: | |
| c=0 | |
| if start<=end: | |
| c=(start-32)*5/9 | |
| print(start,int(c)) | |
| start = start + step | |
| else: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
| import math | |
| def isPerfectSquare(x): | |
| s = int(math.sqrt(x)) | |
| return s * s == x | |
| def isFibonacci(n): | |
| return isPerfectSquare(5 * n * n + 4) or isPerfectSquare(5 * n * n - 4) |
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
| """ | |
| Getting Prime Number using SieveOfEratosthenes | |
| """ | |
| l=int(input()) | |
| p=2 #set the starting node | |
| prime = [True for i in range(l + 1)] #create a prime list and make all elements set to TRUE | |
| prime[0] = False | |
| prime[1] = False | |
| while p*p <=l: | |
| if prime[p]==True: |
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 merge(a1,a2,a): | |
| i=0 | |
| j=0 | |
| k=0 | |
| while i<len(a1) and j<len(a2): | |
| if a1[i]<a2[j]: | |
| a[k]=a1[i] | |
| k=k+1 | |
| i=i+1 | |
| else: |
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 partion(a,si,ei): | |
| pivot=a[si] | |
| c=0 #count number of elements which are greater than initial pi[si] | |
| # below loop use to count the number of elements are greater than initial pi | |
| for i in range(si,ei+1): | |
| if a[i]<pivot: | |
| c=c+1 | |
| a[si+c],a[si]=a[si],a[si+c] #swap | |
| pivot_index=si+c |