# This program is written to read the file "orders.txt" that stores separate order details
# on each line in the file, with six items per line as follows :
# ShoeStyle(e.g. Womens/Mens/Children) ShoeType (sandals/runners/dress/school/boat)
# Shoeitemcode(NNNNX) ShoeSize Price ShopAddress

def menu():
print "\n\tWarehouse dispatch system Menu\n"
print "1. Display all the orders on file"
print "2. Display a list of the ShoeStyle and ShoeType of all items ordered"
print "3. Display the order details given a particular item code"
print "4. Display the item number of the cheapest item on order"
print "5. Display the order details for the largest shoe size on order"
print "6. Display the total number of items in the order"
print "7. Count and display the Shoe Style and ShoeType of all shoes ordered for a specified Shop Address"
print "8. Display the Shoe Type and price for all ordered items in a given Shoe Style (womens/mens/children)"
print "9. Has a specified Shoe Code been ordered? For which Store Location?"
print "10. Display the cost of a particular item, given the line of data from the orders file"
print "11. Calculate the total cost of the entire order"
print "12. Add details for a new order to the orders file"
print "20. Exit"

# Displays (unformatted) all details of all of the orders in the orders.txt input file
def displayFile(inf):
for line in inf:
# display the current line without the end-of-line character, '\n'
print line[:-1]
return

# displays a list of ShoeStyle and ShoeType of all the items ordered
def displayItemNames (inf):
print "not yet implemented"
#for line in inf:
# not yet implemented
return

# Returns the itemcode of the largest (size) shoe purchased
def findLargestItem(inf):
maxsize = 0 # this initial value is set to be zero so that the real max is found
for line in inf:
itemcode = string.split(line)[ITEM_CODE] # identify the item code
size = eval(string.split(line)[SIZE]) # identify the item size
# if the item size is below the current minimum then
# change the stored minimum size and the associated item name
if size > maxsize:
maxsize = size
maxitem = itemcode
return maxitem #return itemcode found as maximum

# Find the total number of purchased items in the order
def findNumberOfItems(inf):
total = 0 # temporary only, for testing choice == 6 main()
# not yet implemented
# count all lines in file and return total count
return total

# Check whether a specified item has been ordered and if so, which store location
def itemPurchased(inf, specifiedItem):
# set variable found to False
found = False
# for each line of the file
# identify the item code
# if the item code matches the specified item
#set found to True
if found:
return string.split(line)[SHOPADDRESS]
else:
return ""
# return the value of purchased to main()

# Calculate the total cost of purchasing a given single item
# not yet implemented - add function here

Q. The following pseudocode describes the logic of the function findNumberOfItems() (option 6). Convert the pseudocode to Python code:
Define function findNumberOfItems(inf)
initialise the total
for each line in the file,
add 1 to the total
return the total