Мне нужно сократить число, полученное в результате расчета, до наименьшего возможного значения, при этом его легко читать, например, 999 000 - 999 000 и 999 000 000 - 999 м.
Мне кажется, у меня есть кодМне нужно, но я не уверен, как я должен реализовать это в моем коде
while True:
bands = input("Please enter your first band colour: ").upper()
print("")
if bands== 'BLACK':
print("The colour black may only be entered in the 2nd or 3rd colour slots.")
continue
bands1 = input("Please enter your second band colour: ").upper()
print("")
bands2 = input("Please enter your third band colour: ").upper()
print("")
print("Ohm value of resistor:", (dict[bands]*10 + dict[bands1]) * (10 ** dict[bands2]),"Ω", )
def print_prefix(value):
prefix=('', 'K', 'M', 'G')
i = 0
if (1000<bands//1000**i):
i=i+1
print(str(value/(1000**i))+prefix[i])
Я ожидаю, что результат будет сокращен, чтобы можно было добавить префикс