Created
August 27, 2020 19:32
-
-
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)
This file contains 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
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