Merhaba, proje geliştirmek adına basit bir script yazmak istedim. Bu script Celsius'tan Fahrenheit'a, Fahrenheit'tan Celsius'a sıcaklık değerleri dönüştürüyor. Yorumlarınızı, ve daha iyi olması için tavsiyelerinizi, eksiklerimi belirtmenizi bekliyorum.
Python:
startMessage = """
(1) - Celsius to Fahrenheit
(2) - Fahrenheit to Celsius
"""
a = True
while a:
print(startMessage)
choice = input('Enter the action you want to do (to quit, press q): ')
if choice == "q":
print('Exiting the script...')
a = False
elif choice == "1":
try:
tc = int(input("Enter the value you want to convert: "))
tf = (tc * 9/5) + 32
print("{} celsius is equal to {} fahrenheit.".format(tc, tf))
except ValueError:
print("Only numbers are valid, please try again...")
elif choice == "2":
try:
tf = int(input("Enter the value you want to convert: "))
tc = (tf - 32) * 5/9
print("{} fahrenheit is equal to {} celsius.".format(tf, tc))
except ValueError:
print("Only numbers are valid, please try again...")
else:
print("You entered an invalid value, please try again...")