<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># produce1.py
# Written by Todd Wareham for CS 2500
"""
Given the names of various produce items as a command-line arguments, prints
 the recognition-status of each item (fruit/vegetable/unrecognized) and the
 final percentage of recognized produce items (out of all items).
"""

import sys

if len(sys.argv) &lt; 2:
    print "usage: ", sys.argv[0], " produce1 produce2 ..."
    sys.exit(1)

numProduce = numNonProduce = 0

for food in sys.argv[1:]:
    if ((food == "apple") or
        (food == "orange") or
        (food == "banana")):
        print food, "is a fruit"
	numProduce += 1
    elif ((food == "potato") or
          (food == "carrot")):
        print food, "is a vegetable"
	numProduce += 1
    else:
        print food, "is not recognized produce"
	numNonProduce += 1

print "Produce index: ",  \
      ((numProduce * 1.0) / (numProduce + numNonProduce)) * 100, "%"

</pre></body></html>