90.2K
Verified Solution
Link Copied!
# Initialize
reimbursment = [3, 4, 6]
expenses = []
flag = 'y'
while flag == 'y' :
miles = float(input( ' Miles? ' ))
trip = input( ' Trip i in state, o out of state, f foreign? ' )
if trip == ' i ' :
rate = reimbursement [0]
elif trip == ' o ' :
rate = reimbursement [1]
else:
rate = reimbursement [2]
reimburse = miles * rate
expenses.append(reimburse)
flag = input( ' Another reimburse y yes n no? ' )
print(sum(expenses))
Assuming that during the execution of the program the user inputs the following data:
Miles? 121
Trip i in state, o out of state, f foreign? i
Another reimbursement y yes n no? y
Miles? 114
Trip i in state, o out of state, f foreign? o
Another reimbursement y yes n no? y
Miles? 103
Trip i in state, o out of state, f foreign? f
Another reimbursement y yes n no? n
Which is the value of sum(expenses) at the end of the execution of the program?
Answer & Explanation
Solved by verified expert