Fucoess
Fucoess
binario
def binario_para_decimal(nb):
potencia = 0
ndec = 0
for c in nb[::-1]:
i = (2 ** potencia) * int(c)
potencia += 1
ndec += i
return ndec
fatorial
def calcular_fatorial(num):
total = 1
fatorial = num
while num != 0:
total = total * num
num = num - 1
return total
resultado = calcular_fatorial(numero)
while nd > 0:
resto = nd % 2
nd = nd // 2
nbin = nbin + str(resto)
return nbin[::-1]
print(f'Resultado: {numero_binario}')
palavras invertidas
def inverter_texto(texto):
return texto[::-1]
(texto) = input("Digite uma palavra: ")
textoinvertido = inverter_texto(texto)
print(textoinvertido)
primos
def e_primo(num):
total = 0
c = num
while c != 0:
if num % c == 0:
total += 1
c -= 1
if total > 2:
return False
else:
return True
pares e impares
def pares_impares(x, y):
numeros_pares = []
numeros_impares = []