Created
August 30, 2018 06:16
-
-
Save qiansen1386/bd9c0d18ed3ba9ba4f6a7e5f1dc0347d to your computer and use it in GitHub Desktop.
This file contains 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
def calc(total,people,treat,split_among): | |
amt = {} | |
plate = total/(sum(people.values())+treat) | |
print("{0:.2f} per plate\n".format(plate)) | |
for k,v in people.items(): | |
print("{} consumed {}".format(k,v)) | |
amt[k] = plate * v | |
else: | |
print() | |
treat_amt = treat * plate | |
avg_carry = treat_amt/len(split_among) | |
for n in split_among: | |
amt[n] += avg_carry | |
for k,v in amt.items(): | |
print("{0} please give Paris ${1:.2f}".format(k,v)) | |
else: | |
print() | |
if __name__ =="__main__": | |
total = 60.00 | |
people = {"QS":9,"PY":5,"NKM":8,"elder":6} | |
treat = 6 | |
split_among = {"QS","PY","NKM"} | |
calc(total,people,treat,split_among) | |
input("Please press Enter to exit...") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment