Created
July 1, 2024 03:24
-
-
Save adityasuseno/0ad45d1e9e71a4f7d117a329b024912a to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python3 | |
# Python script untuk mengkonversi detik ke menit dan jam | |
try: | |
n = int(input("Masukan Detik : ")) # minta detik yang ingin dikonversi | |
if n < 0: | |
print("Masukan angka positif saja!") # jika kurang dari nol detik | |
else: | |
print(n // 3600, "Jam") # floor division dengan 3600 | |
print(n % 3600 // 60, "Menit") # modulus 3600 lalu floor division dengan 60 | |
print(n % 60, "Detik") # modulus 60 | |
except: | |
print("Masukan bilangan bulat saja!") # error jika user memasukan bukan bilangan bulat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment