Skip to content
Menu
Daniel J. Pierce
  • C#
  • Games
  • Graphics
  • Math
  • Python
  • Tynker
  • Unity
Daniel J. Pierce

Number Base Converter 2.0a0

Posted on July 6, 2017January 20, 2024

import time
import sys
import math
import mod
print("Number Base Converter 2.0a0")
print("Program by science64.com")
try:
    baselimit = mod.baselimit()
    unary = mod.unary()
    printable = mod.printables()
    base = mod.base()
    if int(mod.modified) == 1:
        print(str(mod.name))
        print('Mod by ' + str(mod.by))
except NameError:
    print('The program cannot run without the stuff in mod.py, please reload this page')
    sys.exit()
inmn = 0
for l in range(baselimit):
    try:
        printl = len(str(printable[inmn])) #printables(inmn)
        inmn = inmn + 1
        if int(printl) > 1:
            print("We've detected that you have entered a number with a lenght more than 1.")
            print("It's not our fault if the program is finiky.")
            break
    except IndexError:
        break
inm = 0
for x in range(int(baselimit)):
    try:
        baseprint = base[int(inm) - 1]
    except IndexError:
        baseprint = 'Error'
        while True:
            print("Hey, you're your modifying is uncontainable, We can't work with it because variable base stops at " + str(inm))
            print("Please fix this, because you arn't getting past this massage, no matter what you type in.")
            print("Type'/mod-admin' for the results")
            
            error = input()
            if str(error) == '/mod-admin':
                print('baselimit = ' + str(baselimit) + ' and default baselimit = 36')
                inp = 1
                for x in range(int(baselimit)):
                    try:
                        baseprint = base[int(inp) - 1]
                    except IndexError:
                        baseprint = 'Error'
                    try:
                        D = printable[int(inp) - 1]
                    except IndexError:
                        D = 'Error'
                    print(str(inp) + " " + str(baseprint) + " " + str(D))
                    inp = int(inp) + 1
    try:
        D = printable[(inm) - 1]
    except IndexError:
        D = 'Error'
        while True:
            print("Hey, you're your modifying is uncontainable, We can't work with it because variable printable stops at " + str(inm))
            print("Please fix this, because you arn't getting past this message, no matter what you type in.")
            print("Type'/mod-admin' for the results")
            
            error = input()
            if str(error) == '/mod-admin':
                print('baselimit = ' + str(baselimit) + ' and default baselimit = 36')
                inp = 1
                for x in range(int(baselimit)):
                    try:
                        baseprint = base[int(inp) - 1]
                    except IndexError:
                        baseprint = 'Error'
                    try:
                        D = printable[int(inp) - 1]
                    except IndexError:
                        D = 'Error'
                    print(str(inp) + " " + str(baseprint) + " " + str(D))
                    inp = int(inp) + 1
    
while True:
    print("Enter the base you want to convert with.")
    print("Hey, you can only enter a number between 1 and " + str(baselimit) + "!")
    print("Hey, if you want to modify the program, type '/mod'.")
    variable = input()
    try:
        if str(variable) == '/mod':
            print("Step 1: Go into the Modifing Section.")
            print("Step 2: Make sure 'mod = 1' in the Modifying Section.")
            print("Step 3: Make 'baselimit' equal to whatever number in the Modifying Section.")
            print("Step 4: Make 'unary' equal to whatever you want it in the Modifying Section.")
            print("Step 5: If 'baselimit' is above " + str(baselimit) + " add the name in the 'base' in the Modifying Sections")
            print("Step 6: Add a number in 'printables' by adding a comma at the end but in the ")
            print("barckets and adding something on the same line in the Modifying Section")
            continue
        elif str(variable) == '/mod-admin':
            print('baselimit = ' + str(baselimit) + ' and default baselimit = 36')
            inp = 1
            for x in range(int(baselimit)):
                try:
                    baseprint = base[int(inp) - 1]
                except IndexError:
                    baseprint = 'Error'
                try:
                    D = printable[int(inp) - 1]
                except IndexError:
                    D = 'Error'
                print(str(inp) + " " + str(baseprint) + " " + str(D))
                inp = int(inp) + 1
            continue
        elif int(variable) > int(baselimit):
            print("Hey, You can't enter a number qreater than " + str(baselimit) + ".")
            continue
        elif int(variable) < 1:
            print("Hey, you can't enter a number below 1.")
            continue
        elif int(variable) < int(baselimit):
            baseprint = base[int(variable) - 1]
            
    except ValueError:
        print("Hey, that's not a number or a valid command, please enter a number.")
        continue
    
    if int(variable) > 1:
        print("How many digits do you want your conversion to be?")
        try:
            exponent = int(input())
        except ValueError:
            print("Hey's that's not a number, please enter a number")
            continue
    if int(variable) > 1:
        print("What do you want the decimal number place value limit be?")
        decimal = input()
        print("Decimal to " + str(baseprint) + ' ' + str(exponent) + '-bit Converter')
    if int(variable) == 1:
        print("Decimal to Unary Converter")
    while True:
        if int(variable) > 1:
            limit = int(variable) ** int(exponent)
            print("Enter a number between 1 and " + str(limit) + ".")
            print("Type '/reset' if you are not satisfied.")
        elif int(variable) == 1:
            print("Type '/reset' if you arn't satisfied.")
        theirNumber = input()
        try:
            if str(theirNumber) == '/reset':
                break
            elif float(variable) == 1:
                for i in range(int(theirNumber)):
                    print(str(unary), end='')
            elif int(variable) > 1:
                if float(theirNumber) > int(limit):
                    print('Please type a number less than or equal to ' + str(limit))
                elif float(theirNumber) < int(limit) - (int(limit) * 2):
                    print('Please type a number qreater than or equal to -' + str(limit))
                elif float(theirNumber) <= int(limit):
                    if float(theirNumber) < 0:
                        print('-', end='')
                        theirNumber = abs(theirNumber)
                    for f in reversed(range(int(exponent))): 
                        for n in reversed(range(int(variable))): 
                            if float(theirNumber) >= n*float(variable)**f:
                                D1 = printable[n]
                                print(D1, end='')
                                theirNumber = abs(float(theirNumber) - n*float(variable)**f)
                                break
                    print('.', end='')
                    f = 0
                    for y in reversed(range(int(decimal))):
                        for m in reversed(range(int(variable))): 
                            if float(theirNumber) >= m*float(variable)**f:
                                D1 = printable[m]
                                print(D1, end='')
                                theirNumber = abs(float(theirNumber) - m*float(variable)**f)
                                f = f - 1
                                break
                                    

        except ValueError:
            print("Hey, that's not a valid number")
        print("")

Projects

  • Procedure Platforming
  • Particle Simulator
  • AP Computer Science Paint Program
  • Maybe Good Platformer
  • Custom Gravity Test
  • Triangle Types
  • Unity Obstacle Course v1
  • Collapsing rows
  • Java Tic Tac Toe (No AI)
  • Mersenne Prime Tester
  • Rainbow
  • Pong
  • Simple Tkinter Calculator
  • Hexidecimal Converter
  • Snake eats apple
  • Protect the Galactic Empire
  • Hangman
  • Beautiful Colorful Thing
  • Four Dots
  • Frogga
  • Escape asteroids
  • Portals
  • Guess the Number 2.0
  • Illogical
  • Tic Tac Toe
  • Guess the Number
  • Ultimate Calculator 1.0.0a0
  • Prime Number Tester
  • Number Base Converter 2.0a0
  • Number Base Converter 1.1
  • Python Equation Calculator
©2025 Daniel J. Pierce | WordPress Theme by Superb WordPress Themes