Advertisement
obernardovieira

Verificar se é divisor

Nov 14th, 2013
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. def strtolist(string) :
  2.         lista = []
  3.         while True:
  4.                 x = string.find(',')
  5.                 if x == -1:
  6.                         num = string
  7.                         lista.append(int(num))
  8.                         break
  9.                 num = string[0:x]
  10.                 lista.append(int(num))
  11.                 string = string[:0] + string[x+1:]
  12.         return lista
  13.  
  14. def edivisor(num1,num2) :
  15.     if (listanum[0]%listanum[1]) == 0 :
  16.         return True
  17.     else :
  18.         return False
  19.  
  20. num = input("Digite os dois numeros (separados por ,) para verificar se sao divisores: ")
  21. listanum = strtolist(num)
  22. print("É divisor? %s" % edivisor(listanum[0],listanum[1]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement