Skip to content

Commit

Permalink
Merge branch 'dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
erikkristoferanderson authored Aug 7, 2023
2 parents 0fd94ef + 72abbb7 commit 1bb4d41
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
74 changes: 74 additions & 0 deletions choosing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
def choose_from_base(bases):
while True:
choice = input(f"What Base Would You Like To Convert From {bases}: ")
if not choice.isdigit():
print("Input Must Be A Number, Please Try Again.")
continue
choice = int(choice)
if choice not in bases:
print("Not A Choice, Please Try Again.")
continue
break
return choice


def choose_to_base(from_base, bases):

available_bases = []
for base in bases:
if base != from_base:
available_bases.append(base)

while True:
choice_2 = input(f"What Base Would You Like To Convert To? {available_bases}: ")
if not choice_2.isdigit():
print("Input Must Be A Number, Please Try Again.")
continue
choice_2 = int(choice_2)
if choice_2 not in available_bases:
print("Choice Does Not Exist, Please Try Again.")
continue
# if choice_2 == choice: # we've already checked this by not putting from_base in available_bases
# print("Cannot Convert To Same Base, Please Try Again.")
# continue
break
return choice_2


def choose_input_number(from_base):
number = input(f"Please Input A Base {from_base} Number: ")
return number

# Let's move this validation logic out of the input functions
# if not number.isdigit() and choice!=16:
# print("Input Must Be A Number.")
# continue
# if choice in [2,8,10]:
# number = int(number)
# if choice == 2:
# for digit in str(number):
# if digit not in str(binary_digits):
# print("Please Input A Valid Base 2 Number.")
# out=True
# break
# if choice==8:
# for digit in str(number):
# if digit not in str(octal_digits):
# print("Please Input A Valid Base 8 Number.")
# out=True
# break
# if choice==10:
# for digit in str(number):
# if digit not in str(decimal_digits):
# print("Please Input A Valid Base 10 Number.")
# out=True
# break
# if choice==16:
# for digit in str(number):
# if digit not in str(hex_digits):
# print("Please Input A Valid Base 16 Number.")
# out=True
# break
# if out==True:
# continue

3 changes: 3 additions & 0 deletions converting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def convert_base(from_base, to_base, input_number):
# todo implement me
pass
2 changes: 2 additions & 0 deletions validating.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def validate_input_number(from_base, input_number):
pass # todo implement

0 comments on commit 1bb4d41

Please sign in to comment.