Skip to content

Instantly share code, notes, and snippets.

@qiansen1386
Created August 30, 2018 06:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qiansen1386/bd9c0d18ed3ba9ba4f6a7e5f1dc0347d to your computer and use it in GitHub Desktop.
Save qiansen1386/bd9c0d18ed3ba9ba4f6a7e5f1dc0347d to your computer and use it in GitHub Desktop.
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