28 lines
1.1 KiB
Python
28 lines
1.1 KiB
Python
#performs the conversion and prints to the console
|
|
def ConvertToMiles():
|
|
kilometers = float(input("Please provide a number of kilometers that you would like to convert to miles: "))
|
|
converted_to_miles = kilometers * 0.62
|
|
print(kilometers, " kilometer(s) is/are equal to " , converted_to_miles , " miles.")
|
|
askaboutrepeating()
|
|
|
|
#Ask the users if they would like to do it again.
|
|
def askaboutrepeating():
|
|
print("Looks like that provided you a converted number. Do you want to convert another number? ")
|
|
answer = str(input("Please respond with yes (y) or no (n) :"))
|
|
if answer == "y":
|
|
ConvertToMiles()
|
|
if answer == "n":
|
|
exit
|
|
else:
|
|
print("Woah, something about what you typed was definitley not correct.")
|
|
askaboutrepeating()
|
|
|
|
# Defines what the script is going to do and calls upon the earlier defined Convert function
|
|
def main():
|
|
print("Welcome!\n\n This application was made by David Kifer to take a quantity of kilometers and convert them to miles. In the following prompt, you will be asked to provide the amount of kilometers\n\n ")
|
|
ConvertToMiles()
|
|
|
|
# Call the main app to kick off the app
|
|
main()
|
|
|