Python Editor — Persistent Snapshot and Load from File

Python Editor — Load from File + Persistent Snapshot (CRX)

Python Editor — Persistent Snapshot + Load from File

Autosave snapshot (code + output) to localStorage. Load/Save snapshots to file. Floating output available.
Output & Logs
Output will appear here after running your code.
Loaded packages: none
Editor: Ace — language: python
Ready
Tip: Editor autosaves a snapshot ({code, output}) to localStorage. Use Save/Load buttons to exchange snapshots as files.

3 Comments

Champak Roy said…
Pascal's Triangle in Python

def pascal(y,x):
if x==1:
return 1
if y==x:
return 1
return pascal(y-1,x-1) + pascal(y-1,x)

n=5
for y in range(1,n+1):
for space in range(1, n-y+1):
print(" ",end="")
for x in range(1,y+1):
value=pascal(y,x)
print(value,end=" ")
print()
Champak Roy said…
Palindrome checker


def isPalindrome(n):
copy=n
reverse=0
while n>0:
rem=n%10
n=n//10
reverse=reverse*10 + rem
if copy==reverse:
return True
return False
x=int(input())

result=isPalindrome(x)
if result:
print(f"{x} is a palindrome")
else:
print(f"{x} is not a palindrome")
Champak Roy said…
Palindrome numbers

def isPalindrome(n):
copy=n
reverse=0
while n>0:
rem=n%10
n=n//10
reverse=reverse*10 + rem
if copy==reverse:
return True
return False

x=int(input())
if isPalindrome(x):
print("+ve=",x,"-ve=",x)
else:
copy=x
while True:
if isPalindrome(x):
print(x)
break
x+=1
p=x
x=copy
while True:
if isPalindrome(x):
print(x)
break
x-=1
n=x
print("+ve=",p,"-ve=",n)

Post a Comment

3 Comments

  1. Pascal's Triangle in Python

    def pascal(y,x):
    if x==1:
    return 1
    if y==x:
    return 1
    return pascal(y-1,x-1) + pascal(y-1,x)

    n=5
    for y in range(1,n+1):
    for space in range(1, n-y+1):
    print(" ",end="")
    for x in range(1,y+1):
    value=pascal(y,x)
    print(value,end=" ")
    print()

    ReplyDelete
  2. Palindrome checker


    def isPalindrome(n):
    copy=n
    reverse=0
    while n>0:
    rem=n%10
    n=n//10
    reverse=reverse*10 + rem
    if copy==reverse:
    return True
    return False
    x=int(input())

    result=isPalindrome(x)
    if result:
    print(f"{x} is a palindrome")
    else:
    print(f"{x} is not a palindrome")

    ReplyDelete
  3. Palindrome numbers

    def isPalindrome(n):
    copy=n
    reverse=0
    while n>0:
    rem=n%10
    n=n//10
    reverse=reverse*10 + rem
    if copy==reverse:
    return True
    return False

    x=int(input())
    if isPalindrome(x):
    print("+ve=",x,"-ve=",x)
    else:
    copy=x
    while True:
    if isPalindrome(x):
    print(x)
    break
    x+=1
    p=x
    x=copy
    while True:
    if isPalindrome(x):
    print(x)
    break
    x-=1
    n=x
    print("+ve=",p,"-ve=",n)

    ReplyDelete