Question

IN python # Given these test lists to work with: salesDollars = [ 20, 30, 35,...

IN python

# Given these test lists to work with:

salesDollars = [ 20, 30, 35, 15, 60, 100]

personnelCosts = [ 15, 25, 30, 10, 55, 95]

salesPersons =[ "jo", "mo", "ko", “curley”, “jack”,”gunnar”]

A. Write a generic function that will take two numeric list parameters, of equal length,

calculate the total of list1 – total of list 2

and return a triple of numbers, (totalOfList1, totalOfList2, difference of list1 and list2 totals.

B. Test your function with salesDollars and personnelCosts, print your result.( should show 3 values)

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def diffTotalLists(list1, list2):
    total1 = 0
    total2 = 0
    for i in range(len(list1)):
        total1 += list1[i]
        total2 += list2[i]
    return (total1,total2,total1-total2)

# Testing
salesDollars = [ 20, 30, 35, 15, 60, 100]
personnelCosts = [ 15, 25, 30, 10, 55, 95]
print(diffTotalLists(salesDollars,personnelCosts))

Add a comment
Know the answer?
Add Answer to:
IN python # Given these test lists to work with: salesDollars = [ 20, 30, 35,...
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
  • Python. Write a function swap_lists that takes in two lists and swap their elements in place....

    Python. Write a function swap_lists that takes in two lists and swap their elements in place. You can not use another list. You can not return lists. Input lists have the same size. def swap_lists(alist1, alist2): """Swaps content of two lists. Does not return anything. >>> list1 = [1, 2] >>> list2 = [3, 4] >>> swap_lists(list1, list2) >>> print(list1) [3, 4] >>> print(list2) [1, 2] >>> list1 = [4, 2, 6, 8, 90, 45] >>> list2 = [30, 41,...

  • Can someone fix this python program? I'm trying to do three things: Create a function that...

    Can someone fix this python program? I'm trying to do three things: Create a function that takes in a string as a parameter. Then create a dictionary of characters to integers, where the integer represents how many times the number of times the character appears in the word. Create a function that takes two lists as parameters and returns the elements they have in common of the two lists. Ask the user to create a list of numbers and keep...

  • 1. Define a function in python that returns the sum of the following 4 lists. Remember...

    1. Define a function in python that returns the sum of the following 4 lists. Remember to store and re- use your code instead of summing the values for each list 4 times. Hence, define a function that takes as an argument a list and returns the sum of values. Copy the following lists and paste them in a Python file after you define the sum_of_values function Call the function and pass to it a different list each call as...

  • use python 2a. Union (1 points) Make a union function which takes in 2 lists as...

    use python 2a. Union (1 points) Make a union function which takes in 2 lists as parameters and returns a list. It should return a list that contain all elements that are in either list. Your results list should contain no duplicates. For example, if the two lists are [1,5,6,5, 2] and [3,5, 1,9] then the result list is (1,5,6,2,3,9). Note that the list sizes don't have to be equal. Note that the input lists could have duplicates, but your...

  • All of the problems must be done in Haskell. You may download a local IDE or...

    All of the problems must be done in Haskell. You may download a local IDE or use [this website.][https://repl.it/languages/haskell]. You are not allowed any functions that trivialize a problem! Here are some examples of lists you can test your solutions on: let list1 = [5, 10, 15, 20, 25, 30] let list2 = [50, 100, 150, 200, 250, 300] Write a function that returns the maximum value in a list. Write a function that returns the nth element in the...

  • Using the Python program be able to identify or discuss the following: A good test plan...

    Using the Python program be able to identify or discuss the following: A good test plan – how would you determine that it is working? Limitations of the program – what would you do to enhance it? Output improvement – what would you add to improve output? Examples of local variables – name, types, and scope Reason why global variables are not recommended Examples of constants Use of Boolean variable Use of floating point variable Use of integer variable Math...

  • Deletion of List Elements The del statement removes an element or slice from a list by position....

    Deletion of List Elements The del statement removes an element or slice from a list by position. The list method list.remove(item) removes an element from a list by it value (deletes the first occurance of item) For example: a = ['one', 'two', 'three'] del a[1] for s in a: print(s) b = ['a', 'b', 'c', 'd', 'e', 'f', 'a', 'b'] del b[1:5] print(b) b.remove('a') print(b) # Output: ''' one three ['a', 'f', 'a', 'b'] ['f', 'a', 'b'] ''' Your textbook...

  • Test ADTs: Linked Lists, Stacks and Queues (Python and with proper indentation for better understanding please)....

    Test ADTs: Linked Lists, Stacks and Queues (Python and with proper indentation for better understanding please). Create a program that will choose 30 objects with an attribute of random number between 1 and 100. Place each object it in a queue. From that each object will exit the queue in the order that it entered two waiting stacks. Sort those stacks and create two doubly circular linked lists from those stacks. Merge those lists into one doubly circular linked list....

  • In Python Question 3 (13 points): Purpose: To practice your ability to modify lists and compute...

    In Python Question 3 (13 points): Purpose: To practice your ability to modify lists and compute with lists of lists Degree of Difficulty: Moderate For this question, you are given some population estimates, by age group, from Statistics Canada for some provinces. Starter File a5q3 starter.py is a file that contains a list of lists, to which the variable Pop-data refers, which represents 2020 population numbers. The first item in Pop_data is a list whose first item is the string...

  • NOTE: USE PYTHON CS160 Computer Science Lab 14 Working with lists, functions, and files Objective: Work...

    NOTE: USE PYTHON CS160 Computer Science Lab 14 Working with lists, functions, and files Objective: Work with lists Work with lists in functions Work with files Assignment: Part 1: Write a program to create a text file which contains a sequence of test scores. Ask for scores until the user enters an empty value. This will require you to have the scores until the user enters -1. After the scores have been entered, ask the user to enter a file...

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