#construct d
d = {"ATL": {"wins": 7, "losses": 2, "ties": 2},
"CHC": {"wins": 9, "losses": 2, "ties": 2}
}
# [(0.611,"ATL"), (0.876,"CHC")]
result = []
for tcode in d:
p = (d[tcode]["wins"] + 0.5*d[tcode]["ties"])/(d[tcode]["wins"] + d[tcode]["losses"] + d[tcode]["ties"])
result.append((round(p,3),tcode))
print(result)
[(0.727, 'ATL'), (0.769, 'CHC')]
sorted_result = sorted(result,reverse=True)
sorted_result
[(0.769, 'CHC'), (0.727, 'ATL')]
for p in sorted_result:
print("????".format(p[1],p[0]))
CHC 0.769 ATL 0.727
teams = ["ATL", "CHC"]
d2 = {"wins": {"ATL": 7, "CHC": 9},
"losses": {"ATL": 2, "CHC": 2},
"ties": {"ATL": 2, "CHC": 2}
}
result = []
for tcode in teams:
p = (d2["wins"][tcode] + 0.5*d2["ties"][tcode])/(d2["wins"][tcode] + d2["losses"][tcode] + d2["ties"][tcode])
result.append((round(p,3),tcode))
print(result)
[(0.727, 'ATL'), (0.769, 'CHC')]
print("Hello",end="")
print("How are you?")
HelloHow are you?
print("Hello","How are you?")
Hello How are you?