Answer to Question #68736 in Python for Henry John

Question #68736
1.You are creating an inventory management system in Python. You want the following features:

The name of every item should be linked to its stock level and expiry date
The order of the items in the database is not a priority
You need to be able to easily lookup data for each item


Which is the best representation of the optimal data structure you should use to manage the data in this application?
Canned Soup , [45 , 16/12/2016]

‘Canned Soup’ ’45’ ’16/12/2016’

{ ‘Canned Soup’: [45, '16/12/2016'] }

‘Canned Soup, 45, 16/12/2016’

[ ‘Canned Soup’ , 45 , 16/12/2016 ]

def inventory(item,stock_level,expiry)

{ ‘Canned Soup’: 45, ‘Canned Soup’:16/12/2016 }

2.Which of the following best describes a LIST comprehension?

lc = [ x * 2 for x in [1, 2, 3] ]

lc = {x for x in ‘apple’ if x not in [‘a’, ‘e’, ‘i’]}

lc = (x for x in ‘apple’ if x not in [‘a’, ‘e’, ‘i’])

lc = x * 2 for x in [1, 2, 3]’

None of the above
1
Expert's answer
2017-06-09T05:46:03-0400
Answers are:
1. { ‘Canned Soup’: [45, '16/12/2016'] }
2. lc = [ x * 2 for x in [1, 2, 3] ]

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS