Profile cover photo
Profile photo
Amaury Gonçalves Costa
105 followers
105 followers
About
Communities and Collections
View all
Posts

Post has attachment
Amaury Gonçalves Costa commented on a post on Blogger.
Boa tarde galera!!! Segue aí, o mesmo traduzido em Python. Segue aí:


import re

def validaCNS(numero):
if re.match(r'[1-2]\d{10}00$[0-1]\d$',numero) or re.match(r'[7-9]\d{14}$',numero):
return somaPoderada(numero) % 11 == 0


def somaPoderada(numero):
i = 0
soma = 0
while i<len(numero):
soma = soma+int(numero[i]) * (15 - i)
i = i+1
return soma


res = validaCNS("Numero CNS desejado")
if res:
print("CNS Valido!")
else:
print("CNS Invalido!")
Add a comment...

Post has attachment
Add a comment...

Post has attachment
Add a comment...
Wait while more posts are being loaded