Skip to content

Instantly share code, notes, and snippets.

@kavilivishnu
Created August 27, 2020 19:32
Show Gist options
  • Save kavilivishnu/9f6b800bb794910d9dff360d7d9b1423 to your computer and use it in GitHub Desktop.
Save kavilivishnu/9f6b800bb794910d9dff360d7d9b1423 to your computer and use it in GitHub Desktop.
My own timer code using recursion (2 codes wit same structure but different output)
My own timer code using recursion (2 codes wit same structure but different output)
import time
def clock_1(i, j):
if i == 0 and j == 60:
return
else:
if i != 0 and j != 60:
clock_1(i - 1, j + 1)
time.sleep(1)
print(i, ":", j)
i = 60
j = 0
clock_1(i, j)
--------------------------------------------------------------
import time
def clock_1(i, j):
if i == 0 and j == 0:
return
else:
if i != 0:
clock_1(i - 1, j)
time.sleep(1)
if i != 0 and j == 0:
clock_1(i, j - 1)
print(i, ":", j)
i = 60
j = 60
clock_1(i, j)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment