SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 313 Weeks Ago, 6 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 11 Dec 2017 My Price 10.00

inventory_items which has the following items.

2. a. You need to create a file of inventory_items which has the following items.  Use a loop to read in each value until exit is entered for the item_name.  This input represents the item_name, number_sold, price_item, and cost_item.

Blue Pens

400

1.39

0.75

No. 2 Pencils

1000

0.25

0.1

Notebooks

500

6.99

3.47

 

For each item entered, create a string with the values separated by commas.  One item is shown as an example.

Blue Pens, 400, 1.39, 0.75

 

Write out each item string to file named inventory_items.txt.

 

b. Read in the lines of text and split up string line into a list.  Access the appropriate list elements in order to perform the following calculation for the profit: number_sold * (price_item - cost_item).  Print out the name of the item and the profit with two decimal places of precision.

 

(BONUS) Sum up the profit in order to compute the total profit.

 

THE FOLLOWING ATTACHED FILE IS WHAT I HAVE, BUT I CAN'T FIGURE OUT HOW TO PRINT THE SUM of number_sold * price_item and then print out the profit all in the .txt file

def main():

    item_name=['Blue Pens', 'No.2 Pencil', 'Notebooks']

    number_sold=[400,1000,500]

    price_item=[1.39, 0.25, 6.99]

    cost_item=[0.75, 0.1, 3.47]

    file_opened = False

    try:

        count=len(item_name)

        print (count)

       

        output_file=open("inventory_items.txt","w")

        file_opened=True

        for i in item_name, number_sold,price_item,cost_item:

            print (i,file=output_file)

       

       

   

   

    except KeyboardInterrupt:

        print("Exiting...")

    except PermissionError: #dont have permission

        print ("Permission Error")

    except IsADirectoryError:

        print("Directory is specified and not a file")

    except FileNotFoundError:

        print("File not found")

    finally:

        if file_opened:

            output_file.close()#closes file

Answers

(5)
Status NEW Posted 11 Dec 2017 01:12 PM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)