Advertisement
Guest User

Untitled

a guest
May 27th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. import sys,os
  2. import time
  3.  
  4. s = 0
  5. m = 0
  6. h = 0
  7.  
  8. def temporizador(s,m,h):
  9. print "Defina o tempo desejado: \n"
  10. h = input("Horas: ")
  11. m = input("Minutos: ")
  12. s = input("Segundos: ")
  13. soma = h + m + s #Verifica se ha algum valor para ser temporizado
  14. os.system('clear')
  15. if soma > 0:
  16. while 1:
  17. print '[',h,':',m,':',s,']'
  18. if s >= 1:
  19. s -= 1
  20. elif m >=1:
  21. m -= 1
  22. s = 59
  23. elif h >=1:
  24. h -= 1
  25. m = 59
  26. s = 59
  27. else:
  28. print "Seu tempo acabou!"
  29. time.sleep(1)
  30. os.system('clear')
  31. else:
  32. print "[!]Escolha um numero valido"
  33. menu()
  34.  
  35. def contador(s,m,h):
  36. os.system('clear')
  37. while 1:
  38. print '[',h,':',m,':',s,']'
  39. s += 1
  40. time.sleep(1)
  41. if s >= 60:
  42. s=0
  43. m += 1
  44. if m >= 60:
  45. m = 0
  46. h += 1
  47. os.system('clear')
  48.  
  49. def menu():
  50. num = 0
  51. while num != 1 or 2:
  52. print '''--- Cronos Python 1.0 ---
  53. by: immartins406
  54. 1) Cronometro
  55. 2) Temporizador
  56. '''
  57. try:
  58. num = int(raw_input("Escolha uma opcao:"))
  59. if num == 1:
  60. contador(s,m,h)
  61. elif num == 2:
  62. temporizador(s,m,h)
  63. else:
  64. os.system("clear")
  65. print "[!]Digite um dos numeros abaixo\n"
  66. except NameError:
  67. os.system("clear")
  68. print "[!]Escolha um numero valido"
  69. except ValueError:
  70. os.system("clear")
  71. print "[!]Digite algum dos valores abaixo"
  72. except KeyboardInterrupt:
  73. print"\n"
  74. quit()
  75. menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement