Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# Initialize reimbursment = [3, 4, 6] expenses = [] flag = 'y' while flag == 'y' : miles = float(input( ' Miles? ' ))

# 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? 118

Trip i in state, o out of state, f foreign? i

Another reimbursement y yes n no? y

Miles? 107

Trip i in state, o out of state, f foreign? o

Another reimbursement y yes n no? y

Miles? 141

Trip i in state, o out of state, f foreign? f

Another reimbursement y yes n no? n

Which is the value of the variable expenses[2] at the end of the execution of the program?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial Accounting An International Introduction

Authors: David Alexander

7th Edition

129229583X, 978-1292295831

More Books

Students also viewed these Accounting questions