forked from aiti-ghana-2012/Lab_Python_04
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab04_solution.py
More file actions
75 lines (61 loc) · 1.71 KB
/
Copy pathlab04_solution.py
File metadata and controls
75 lines (61 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
'''
Created on Jun 22, 2012
@author: Annor Theophilus
'''
# Q1
groceries =['bananas','strawberries','apples','bread']
groceries.append('champagne')
print 'Q1 part a results is'
for item in groceries:
print item
print # print a line
groceries.remove('bread')
print 'part b result is'
print #printing a line
for item in groceries:
print item
print
print 'part c results'
print
groceries.sort()
for item in groceries:
print item
print 'Question 2'
print 'results of a : Dictionary'
print 'results of b '
#items=
itemsAndprice = {'Apple':'SPIC_APPLES','Bananas':'SPIC_BANANAS','Bread':'SPIC_BREAD','Carrots':'SPIC_CARROTS','Champagne':'SPIC_CAMPAGNE','Strawberries':'SPIC_STRAWBERRIES'}
# printing the items
for key,value in itemsAndprice.iteritems():
print key,' ',value
print
print 'results of Ques. 2c'
itemsAndprice['strawberries']='WPIC_STRAWBERRIES'
for key,value in itemsAndprice.iteritems():
print key,' ',value
print
print 'results of d is'
itemsAndprice['chicken']='SPIC_CHICKEN'
for key ,value in itemsAndprice.iteritems():
print key,' ',value
print
print
print'------------------'
print 'LISTS'
print
print 'Resultd of'
list_items=['Apple','Bananas','Bread','Carrot','Champagne','Strawberries']
in_stock={'Apple':7.3,'Carrot':10.0,'Bananas':5.5,'Bread':1.0,'Champagne':20.90,'Strawberries':32.6}
print 'items to be Advertised'
print 'items',' ','Prices'
for items in list_items:
if items in in_stock:
print items,in_stock[items]
else:
print items,' out of stock'
print
print ' Tuples'
print
always_in_stock = in_stock.items()
for items in always_in_stock:
print items