Joelg4dea

Python | Multiplicar número (x) veces en sistema numérico (x)

Apr 16th, 2021
597
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pyautogui            # Para obtener los datos
  2. import win32clipboard       # Para copiar los resultados
  3.  
  4. #       Datos de entrada
  5. base = int(pyautogui.prompt('Indique su base [maximo 36]'))
  6. numX = pyautogui.prompt('Ingrese su numero (sin fracciones)')
  7. num = "0"+numX
  8.  
  9. #       Proceso de asignacion
  10. car = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  11. Multis = "Numero multiplicado "+str(base)+" veces:\n\n\n"
  12. numLen = len(num)
  13. MultisV = ""
  14.  
  15. #       Proceso
  16. for a in range(1, base+1, 1):
  17.   for c in range(numLen-1, -1, -1):
  18.     if c == numLen-1:
  19.       lascoct = 0
  20.     numV = int(num[c], base=base)
  21.     cocient = int((numV*a+lascoct)/base)
  22.     numV = (numV*a+lascoct)-(base*cocient)
  23.     lascoct = cocient
  24.     MultisV = car[numV]+MultisV
  25.   Multis = Multis+numX.upper()+"*"+car[a]+" = "+MultisV+"\n"
  26.   MultisV = ""
  27.  
  28. #       Informacion de salida
  29. resul = pyautogui.confirm(Multis, title='Resultado', buttons=['Copiar', 'Cancelar'])
  30.  
  31. #       Copiar al portapapeles
  32. if resul == 'Copiar':
  33.   win32clipboard.OpenClipboard()
  34.   win32clipboard.EmptyClipboard()
  35.   win32clipboard.SetClipboardText(Multis, win32clipboard.CF_TEXT)
  36.   win32clipboard.CloseClipboard()
  37.  
  38. #       Fin del algoritmo
  39. exit()
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×