Question

I have bigger data than this but I can use it as an example. Please, write a python 3.6 code for the question.

expenses = [['De La Fuente', 'Roque', 'NY', 6000, 'Prof. Srvcs.'], ['De La Fuente', 'Roque', 'NY', 6000, 'Prof. Srvcs.'], ['Malliotakis', 'Nicole', 'MA', 40000, 'Television Ads.'], ['Marte', 'Christopher', 'NY', 5152, 'Radio Ads.'], ['Yeger', 'Kalman', 'NY', 23000, 'Campgn Consuls.'], ['Marte', 'Christopher', 'CA', 5711, 'Other: explntion']]

DATA expenses [[De La Euente, Roque, NY, 6000, Prof. Srvcs,], [De La Fuente, Roque, NY, 6000, Prof. Srvcs. [Mall

0 0
Add a comment Improve this question Transcribed image text
Answer #1
expenses = [['De La Fuente', 'Roque', 'NY', 6000, 'Prof. Srvcs.'], ['De La Fuente', 'Roque', 'NY', 6000, 'Prof. Srvcs.'], ['Malliotakis', 'Nicole', 'MA', 40000, 'Television Ads.'], ['Marte', 'Christopher', 'NY', 5152, 'Radio Ads.'], ['Yeger', 'Kalman', 'NY', 23000, 'Campgn Consuls.'], ['Marte', 'Christopher', 'CA', 5711, 'Other: explntion']]

# user input for last name of candidate
last_name = input('Enter the last name of candidate: ')

# for displaying total amount of expenses
expense_amount = [row[3] for row in expenses]
print('Total Expenses', sum(expense_amount))

# for displaying expenses for a particular candidate
candidate_amount = [row[3] for row in expenses if row[0] == last_name]
print('Expenses for candidate with last name', last_name, ':', sum(candidate_amount))

In [4]: runfile ( C:/Users/Administrator/.spyder- py3/ temp.py, wdir=C:/Users/Administrator/. spyder-py3) Enter the last

For help and modification please comment.

Thank You

Add a comment
Know the answer?
Add Answer to:
I have bigger data than this but I can use it as an example. Please, write...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT