[참고] Doing Math With Python - 저자 : AMIT SAHA
'''Unit converter : Miles and Kilometers'''
def print_menu():
print('1. Kilometers to Miles')
print('2. Miles to Kilometers')
def km_miles():
km = float(input('Enter distance in kilometers: '))
miles = km / 1.609 #1마일 = 1.609km
print('Distance in miles: {0}'.format(miles))
def miles_km():
miles = float(input('Enter distance in miles: '))
km = miles * 1.609
print('Distance in kilometers: {0}'.format(km))
if __name__ == '__main__':
print_menu()
choice = input('Which conversion would you like to do?: ')
if choice == '1':
km_miles()
if choice =='2':
miles_km()
'#Python #수학' 카테고리의 다른 글
#날씨 그래프 #Python (0) | 2018.11.06 |
---|---|
#그래프 그리기 #Matplotlib #Python (0) | 2018.11.06 |
#이차방정식(근의 공식)의 해 구하기 #Python (0) | 2018.11.06 |
#곱하기 테이블(구구단) #Python (0) | 2018.11.02 |
#정수의 약수 구하기 #Python (0) | 2018.11.02 |