Create a dictionary (order_dict) that the key is the burger number, and the value is a list of the quantities. For example: order_dict which is  {'1': [10, 3, 78], '2': [35, 0, 65], '3': [9, 23, 0], '4': [0, 19, 43], '5': [43, 0, 21]} Create a dictionary (total_order_dict) that the key is the burger number, and the value is the total of the quantities for that burger. For example: total_order_dict which is {'1': 91, '2': 100, '3': 32, '4': 62, '5': 64} Use "assert to test the values of the total_order_dict For example: expected_result_ototal_order_dict = {'1': 91, '2': 100, '3': 32, '4': 62, '5': 64} assert actual_result_ototal_order_dict['1'] == expected_result_ototal_order_dict['1'] , "The actual result is not the \ same as expected result for the order number 1!" (and test the other elements) The function can be like: def test_sum(): #Testing assert actual_result_ototal_order_dict['1'] == 91, "The actual result is not the \ same as expected result for the order number 1!" Write this dictionary in a csv file which the first is the key (number of the burger ) and the next number after comma is the value ( the total of the quantities for that burger) you can use like this: def write_order_csv(actual_result_ototal_order_dict,outputFile): with open(outputFile, 'w') as outfile: for key in actual_result_ototal_order_dict.keys(): outfile.write("%s,%s\n"%(key,actual_result_ototal_order_dict[key])) #or writer = csv.writer(outfile) writer.writerow(key + actual_result_ototal_order_dict[key]) You main function can be like: if __name__ == "__main__": actual_result_ototal_order_dict = read_order("order.csv") test_sum() print("Everything passed") write_order_csv(actual_result_ototal_order_dict,"outputfile.csv") My code is  import csv order_dict = {'1': [10, 3, 78], '2': [35, 0, 65], '3': [9, 23, 0], '4': [0, 19, 43], '5': [43, 0, 21]} total_order_dict = {} def read_file(): with open ("order.csv",'r') as file: reader = csv.reader(file) for key, values in order_dict.items(): order_dict[key] = sum(values) print(key,sum(values)) total_order_dict = order_dict return total_order_dict def testing_value(): assert total_order_dict["2"] == 100, "The total results is not equal with order_dict" def write_file(read_file): with open ("order.csv",'w') as file: for key in total_order_dict(): read_file. write(key,",",values) if __name__ == "__main__": read_file() testing_value() write_file(read_file) please modify my code to be the same as the output

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
  • Create a dictionary (order_dict) that the key is the burger number, and the value is a list of the quantities.

For example: order_dict which is  {'1': [10, 3, 78], '2': [35, 0, 65], '3': [9, 23, 0], '4': [0, 19, 43], '5': [43, 0, 21]}

  • Create a dictionary (total_order_dict) that the key is the burger number, and the value is the total of the quantities for that burger.

For example: total_order_dict which is {'1': 91, '2': 100, '3': 32, '4': 62, '5': 64}

  • Use "assert to test the values of the total_order_dict

For example:

expected_result_ototal_order_dict = {'1': 91, '2': 100, '3': 32, '4': 62, '5': 64}

assert actual_result_ototal_order_dict['1'] == expected_result_ototal_order_dict['1'] , "The actual result is not the \
same as expected result for the order number 1!"

(and test the other elements)

The function can be like:

def test_sum():
       #Testing
        assert actual_result_ototal_order_dict['1'] == 91, "The actual result is not the \
        same as expected result for the order number 1!"

  • Write this dictionary in a csv file which the first is the key (number of the burger ) and the next number after comma is the value ( the total of the quantities for that burger)

you can use like this:

def write_order_csv(actual_result_ototal_order_dict,outputFile):
                with open(outputFile, 'w') as outfile:
                              for key in actual_result_ototal_order_dict.keys():
                                            outfile.write("%s,%s\n"%(key,actual_result_ototal_order_dict[key]))

                                            #or

                                            writer = csv.writer(outfile)

                                            writer.writerow(key + actual_result_ototal_order_dict[key])

You main function can be like:

if __name__ == "__main__":
           actual_result_ototal_order_dict = read_order("order.csv")
           test_sum()
           print("Everything passed")
           write_order_csv(actual_result_ototal_order_dict,"outputfile.csv")

My code is 

import csv

order_dict =  {'1': [10, 3, 78], '2': [35, 0, 65], '3': [9, 23, 0], '4': [0, 19, 43], '5': [43, 0, 21]}
total_order_dict = {}

def read_file():
    with open ("order.csv",'r') as file:
        reader = csv.reader(file)
        for key, values in order_dict.items():
            order_dict[key] = sum(values)
            print(key,sum(values))
        total_order_dict = order_dict
        return total_order_dict

def testing_value():
     assert total_order_dict["2"] == 100, "The total results is not equal with order_dict"
    
def write_file(read_file):
    with open ("order.csv",'w') as file:
        for key in total_order_dict():
            read_file. write(key,",",values)
if __name__ == "__main__":
    read_file()
    testing_value()
    write_file(read_file)

please modify my code to be the same as the output

order.csv-5
1,10,3,78
2,35,0,65
3,9,23,0
4,0,19,43
5,43,0,21
Transcribed Image Text:order.csv-5 1,10,3,78 2,35,0,65 3,9,23,0 4,0,19,43 5,43,0,21
outputfile.csv-
1,91
2,100
3,32
4,62
5,64
Transcribed Image Text:outputfile.csv- 1,91 2,100 3,32 4,62 5,64
Expert Solution
steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY