Created
March 25, 2020 00:34
-
-
Save gsinclair/71052a24f662285aedad181dc3f18e3d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Initial data, for testing. | |
ItemNo = [31, 42, 27, 81, 99, 46] | |
Description = ["Vase", "Chair", "Painting", "Piano", "Tuba", "Model car"] | |
NumBids = [3, 0, 1, 9, 7, 0] | |
Reserve = [19, 80, 300, 120, 99, 5] | |
Bid = [25, 0, 50, 437, 105, 0] | |
Buyer = [108, None, 199, 176, 155, None] | |
Result = [None, None, None, None, None, None] | |
N = 6 | |
# Some code to show the data that we have. | |
def show_data(): | |
heading = "%4s %-11s %4s %6s %6s %6s %s" % ("I#", "Desc", "#bid", "Reserve", "Bid", "Buyer", "Result") | |
sep = "%4s %-11s %4s %6s %6s %6s %s" % ("--", "----", "----", "-------", "---", "-----", "------") | |
print(heading) | |
print(sep) | |
for i in range(N): | |
it, de, nb = ItemNo[i], Description[i], NumBids[i] | |
re, bi, bu = Reserve[i], Bid[i], Buyer[i] | |
result = Result[i] | |
line = "%4i %-11s %4i %6i %6i %6s %s" % (it, de, nb, re, bi, bu, result) | |
print(line) | |
print() | |
# TASK 3 (things we haven't done yet) | |
# * Display item # and final bid for unsold items (did not meet reserve). | |
# * Display item # of items that received no bids. | |
# * Summary: # sold, # unsold, # unbid (sum of these == total number of items) | |
def calculate_results(): | |
# Determine the result for each item: "Sold", "Unsold", "Unbid" | |
for i in range(N): | |
if NumBids[i] == 0: | |
Result[i] = "Unbid" | |
elif Bid[i] >= Reserve[i]: | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment