Если есть какая-то практика, которую я мог бы избежать или суммировать, которую я мог бы сделать лучше, дайте мне знать
Scale_1 = input("What scale would you like to convert from? [KG/HG/DAG/G/DG/CG/MG]")
Scale_2 = input("What scale would you like to convert to? [KG/HG/DAG/G/DG/CG/MG] ")
Num_1_Con = float(input("What number/amount would you like to convert?"))
KG = "Kilogram"
HG = "Hectogram"
DAG = "Decagram"
G = "Gram"
DG = "Decigram"
CG = "Centigram"
MG = "Milligram"
Yes = "Yes"
No = "No"
if Scale_1 == "KG":
if Scale_2 == "HG":
print("Your answer is:")
print(Num_1_Con * 10)
print("Hectograms")
elif Scale_2 == "DAG":
print("Your answer is:")
print(Num_1_Con * 100)
print("Decagrams")
elif Scale_2 == "G":
print("Your answer is:")
print(Num_1_Con * 1000)
print("Grams")
elif Scale_2 == "DG":
print("Your answer is:")
print(Num_1_Con * 10000)
print("Centigrams")
elif Scale_2 == "CG":
print("Your answer is:")
print(Num_1_Con * 100000)
print("Centigrams")
elif Scale_2 == "MG":
print("Your answer is")
print(Num_1_Con * 1000000)
print("Milligrams")
else:
print("Something went wrong please try again!")
if Scale_1 == "HG":
if Scale_2 == "KG":
print("Your answer is: ")
print(Num_1_Con / 10)
print("Kilograms")
if Scale_2 == "DAG":
print("Your answer is: ")
print(Num_1_Con * 10)
print("Decagrams")
if Scale_2 == "G":
print("Your answer is: ")
print(Num_1_Con * 100)
print("Grams")
if Scale_2 == "DG":
print("Your answer is: ")
print(Num_1_Con * 1000)
print("Decigrams")
if Scale_2 == "CG":
print("Your answer is: ")
print(Num_1_Con * 10000)
print("Centigrams")
if Scale_2 == "MG":
print("Your answer is: ")
print(Num_1_Con * 100000)
print("Milligrams")
if Scale_1 == "DAG":
if Scale_2 == "KG":
print("Your answer is: ")
print(Num_1_Con / 100)
print("Hectograms")
if Scale_2 == "HG":
print("Your answer is: ")
print(Num_1_Con / 10)
print("Hectograms")
if Scale_2 == "G":
print("Your answer is: ")
print(Num_1_Con * 10)
print("Grams")
if Scale_2 == "DG":
print("Your answer is: ")
print(Num_1_Con * 100)
print("Decigrams")
if Scale_2 == "CG":
print("Your answer is: ")
print(Num_1_Con * 1000)
print("Centigrams")
if Scale_2 == "MG":
print("Your answer is: ")
print(Num_1_Con * 10000)
print("Milligrams")
if Scale_1 == "G":
if Scale_2 == "KG":
print("Your answer is: ")
print(Num_1_Con / 1000)
print("Hectograms")
if Scale_2 == "HG":
print("Your answer is: ")
print(Num_1_Con / 100)
print("Hectograms")
if Scale_2 == "DAG":
print("Your answer is: ")
print(Num_1_Con / 10)
print("Decagrams")
if Scale_2 == "DG":
print("Your answer is: ")
print(Num_1_Con * 10)
print("Decigrams")
if Scale_2 == "CG":
print("Your answer is: ")
print(Num_1_Con * 100)
print("Centigrams")
if Scale_2 == "MG":
print("Your answer is: ")
print(Num_1_Con * 1000)
print("Milligrams")
if Scale_1 == "DG":
if Scale_2 == "KG":
print("Your answer is: ")
print(Num_1_Con / 10000)
print("Hectograms")
if Scale_2 == "HG":
print("Your answer is: ")
print(Num_1_Con / 1000)
print("Hectograms")
if Scale_2 == "DAG":
print("Your answer is: ")
print(Num_1_Con / 100)
print("Decagrams")
if Scale_2 == "G":
print("Your answer is: ")
print(Num_1_Con / 10)
print("Grams")
if Scale_2 == "CG":
print("Your answer is: ")
print(Num_1_Con * 10)
print("Centigrams")
if Scale_2 == "MG":
print("Your answer is: ")
print(Num_1_Con * 100)
print("Milligrams")
if Scale_1 == "CG":
if Scale_2 == "KG":
print("Your answer is: ")
print(Num_1_Con / 100000)
print("Hectograms")
if Scale_2 == "HG":
print("Your answer is: ")
print(Num_1_Con / 10000)
print("Hectograms")
if Scale_2 == "DAG":
print("Your answer is: ")
print(Num_1_Con / 1000)
print("Decagrams")
if Scale_2 == "G":
print("Your answer is: ")
print(Num_1_Con / 100)
print("Grams")
if Scale_2 == "DG":
print("Your answer is: ")
print(Num_1_Con / 10)
print("Decigrams")
if Scale_2 == "MG":
print("Your answer is: ")
print(Num_1_Con * 10)
print("Milligrams")
if Scale_1 == "MG":
if Scale_2 == "KG":
print("Your answer is:")
print(Num_1_Con / 1000000)
print("Kilograms")
elif Scale_2 == "HG":
print("Your answer is:")
print(Num_1_Con / 100000)
print("Hectograms")
elif Scale_2 == "DAG":
print("Your answer is:")
print(Num_1_Con / 10000)
print("Decagrams")
elif Scale_2 == "G":
print("Your answer is:")
print(Num_1_Con / 1000)
print("Grams")
elif Scale_2 == "DG":
print("Your answer is:")
print(Num_1_Conn / 100)
print("Decigrams")
elif Scale_2 == "CG":
print("Your answer is")
print(Num_1_Con / 10)
print("Centigrams")
else:
print("Something went wrong please try again!")
while True:
input("What scale would you like to start with?")
Подробнее здесь: https://stackoverflow.com/questions/798 ... -shortened
Мобильная версия