Skip to content

Instantly share code, notes, and snippets.

@rdramos1
Created June 12, 2022 00:13
Show Gist options
  • Save rdramos1/9572dba4483183a80833beba46567404 to your computer and use it in GitHub Desktop.
Save rdramos1/9572dba4483183a80833beba46567404 to your computer and use it in GitHub Desktop.
teste?
#Perguntar o fator e a variavel
fat = input("Digite o fator comum: ") # "x²+3x"
var = input("Digite a variavel usada no fator comum: ") # "x"
#Salvar o texto da fat antiga para remover o x² do x²+3x e contar quantos veses repete o "x"
fat2 = [fat]
vc = int(fat.count(var))
#verificar e pegar os valores que importao do primeiro x ("x²"+3x)
while vc > 0:
loc = int(fat.find(var))
print("loc do x:", loc)
pot=0
num=0
#verificação da potencia
loc=+1
n1=int(fat[loc].find("²"))
if (n1!=-1):
pot=2
print("Tem potencia: ²")
n1=int(fat[loc].find("³"))
if (n1!=-1):
pot=3
print("Tem potencia: ³")
loc=-1
#verificando se tem um numero antes do "x²"
loc=-1
if(loc<0|loc!=0):
loc=+1
print("Nao tem numero")
else:
num=int(fat[loc])
print("Tem numero:", num)
loc=+1
vc=vc-1
fac3 = fat2.__str__().replace("[", " ").replace("]", "").replace("'", "").strip()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment