Question

In: Computer Science

How do I calculate the total of all invoices? Here is my code: # Part F...

How do I calculate the total of all invoices?

Here is my code:

# Part F Calculate the total of invoices

invoices=[]

invoices.append((83,'Electric Sander',7,57.98))
invoices.append((24,'Power Saw',18,99.99))
invoices.append((7,'Sledge Hammer',11,21.50))
invoices.append((77,'Hammer',76,11.99))
invoices.append((39,'Jig Saw',3,79.50))

print('\nThe total of all invoices is', invoice)
for invoice in invoices:
print(invoice)

Solutions

Expert Solution

# Part F Calculate the total of invoices

invoices=[]

invoice = 0

invoices.append((83,'Electric Sander',7,57.98))

invoices.append((24,'Power Saw',18,99.99))

invoices.append((7,'Sledge Hammer',11,21.50))

invoices.append((77,'Hammer',76,11.99))

invoices.append((39,'Jig Saw',3,79.50))

for unit_invoice in invoices:

invoice = invoice + unit_invoice[2]*unit_invoice[3]

print('\nThe total of all invoices is', invoice)

====================================================

SEE OUTPUT

Thanks, PLEASE COMMENT if there is any concern. PLEASE UPVOTE


Related Solutions

Python I want to name my hero and my alien in my code how do I...
Python I want to name my hero and my alien in my code how do I do that: Keep in mind I don't want to change my code except to give the hero and alien a name import random class Hero:     def __init__(self,ammo,health):         self.ammo=ammo         self.health=health     def blast(self):         print("The Hero blasts an Alien!")         if self.ammo>0:             self.ammo-=1             return True         else:             print("Oh no! Hero is out of ammo.")             return False     def...
I'm really confused Junit test case Here is my code. How can I do Junit test...
I'm really confused Junit test case Here is my code. How can I do Junit test with this code? package pieces; import java.util.ArrayList; import board.Board; public class Knight extends Piece {    public Knight(int positionX, int positionY, boolean isWhite) {        super("N", positionX, positionY, isWhite);    }    @Override    public String getPossibleMoves() {        ArrayList<String> possibleMoves = new ArrayList<>();               // check if squares where knight can go are available for it       ...
Here is my fibonacci code using pthreads. When I run the code, I am asked for...
Here is my fibonacci code using pthreads. When I run the code, I am asked for a number; however, when I enter in a number, I get my error message of "invalid character." ALSO, if I enter "55" as a number, my code automatically terminates to 0. I copied my code below. PLEASE HELP WITH THE ERROR!!! #include #include #include #include #include int shared_data[10000]; void *fibonacci_thread(void* params); void parent(int* numbers); int main() {    int numbers = 0; //user input....
I know how to do this with arrays, but I have trouble moving my code to...
I know how to do this with arrays, but I have trouble moving my code to use with linked lists Write a C program that will deal with reservations for a single night in a hotel with 3 rooms, numbered 1 to 3. It must use an infinite loop to read commands from the keyboard and quit the program (return) when a quit command is entered. Use a switch statement to choose the code to execute for a valid command....
I DO NOT have a specific question, my question here is GENERAL HOW TO DETERMINE IF...
I DO NOT have a specific question, my question here is GENERAL HOW TO DETERMINE IF A COMPOUND IS POLAR OR NONPOLAR? I know how to figure about the number of valence electrons and I KNOW how to draw lewis structure, but then I just mess every thing up. I want to know how to determine if it's polar or not. for example: sicl2f2, co2, xef2, xeo4 ... I KNOW how to draw the lewis structure, but this I CANNOT...
Here is my java code. It works and has the correct output, but I need to...
Here is my java code. It works and has the correct output, but I need to add a file and I am not sure how. I cannot use the FileNotFoundException. Please help! import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Exercise { public static void main(String[] args) { Scanner input=new Scanner(System.in); int[] WordsCharsLetters = {0,0,0}; while(input.hasNext()) { String sentence=input.nextLine(); if(sentence!=null&&sentence.length()>0){ WordsCharsLetters[0] += calculateAndPrintChars(sentence)[0]; WordsCharsLetters[1] += calculateAndPrintChars(sentence)[1]; WordsCharsLetters[2] += calculateAndPrintChars(sentence)[2]; } else break; } input.close(); System.out.println("Words: " + WordsCharsLetters[0]); System.out.println("Characters: "...
How would you map invoices by description and quantity, then sort the invoices by quantity? Here...
How would you map invoices by description and quantity, then sort the invoices by quantity? Here is my code: #Part C: Map each invoice tuple containing part description and then quantity, sort by quantity invoices=[] invoices.append((83,'Electric Sander',7,57.98)) invoices.append((24,'Power Saw',18,99.99)) invoices.append((7,'Sledge Hammer',11,21.50)) invoices.append((77,'Hammer',76,11.99)) invoices.append((39,'Jig Saw',3,79.50)) list(map(lambda invoice:invoice[1,2])) invoices.sort(key=lambda invoice:invoice[2]) print('\nSorted by Quantity') for invoice in invoices: print(invoice) this is python
Here is my algorithm: Ask how much time they need to do the assignment(Total hours) Ask...
Here is my algorithm: Ask how much time they need to do the assignment(Total hours) Ask how many days are available Calculate hour per day needed Store time needed per day in a variable 2. How many hours per day are available Store hours available per day in a variable Ask user how much time is spent doing other things Calculate how much time is available per day 24- (# of hours not available) Display how much time is available...
How do I add the information below to my current code that I have also posted...
How do I add the information below to my current code that I have also posted below. <!DOCTYPE html> <html> <!-- The author of this code is: Ikeem Mays --> <body> <header> <h1> My Grocery Site </h1> </header> <article> This is web content about a grocery store that might be in any town. The store stocks fresh produce, as well as essential grocery items. Below are category lists of products you can find in the grocery store. </article> <div class...
JAVA: How do I fix the last "if" statement in my code so that outputs the...
JAVA: How do I fix the last "if" statement in my code so that outputs the SECOND HIGHEST/MAXIMUM GPA out of the given classes? public class app { private static Object minStudent; private static Object maxStudent; public static void main(String args[ ]) { student st1 = new student("Rebecca", "Collins", 22, 3.3); student st2 = new student("Alex", "White", 19, 2.8); student st3 = new student("Jordan", "Anderson", 22, 3.1); student[] studentArray; studentArray = new student[3]; studentArray[0] = st1; studentArray[1] = st2; studentArray[2]...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT