# I want this to be like okay google, siri, alexa. Jeff's plan is to
# add to this throughout the semester.
#
# Goal - make it respond correctly to things like -
# "what is 2 + 3"
# "what is 2 * 3"
# "convert 23 fahrenheit to celsius"
# "convert 1 mile to km"
# "what time is it" (in CITY)
# "random number between 1 and 100"
# "random coin flip"
# "random die roll"
# assume num is going to be some number, from and to are strings
# that could be "miles", "km", ...
def convert(num, units_from, units_to):
if units_from == "miles" and units_to == "km":
return num * 1.609
elif units_from == "km" and units_to == "miles":
return num / 1.609
else:
return None
done = False
while not done:
print("Hello, this is Jeff. What can I do for you?")
# get a line from the user, note that this is a string
line = input("")
# split it into "words"
words = line.split(" ")
# words is a list
whatToDo = words[0]
if whatToDo == 'convert':
number = float(words[1])
unit1 = words[2]
to = words[3]
unit2 = words[4]
print(number, unit1, to, unit2)
if to != 'to':
print('I do not understand.')
continue
result = convert(number, unit1, unit2)
print(result)
elif whatToDo == 'quit':
done = True
print("So long.")