Find answers to your most challenging questions with the help of IDNLearn.com's experts. Find accurate and detailed answers to your questions from our experienced and dedicated community members.
Sagot :
Answer:
quarterback_stats = {
'Aaron Rodgers': {'COMP': 371, 'YDS': 4925, 'TD': 39, 'INT': 8},
'Peyton Manning': {'COMP': 400, 'YDS': 4659, 'TD': 37, 'INT': 11},
'Greg McElroy': {'COMP': 19, 'YDS': 214, 'TD': 1, 'INT': 1},
'Matt Leinart': {'COMP': 16, 'YDS': 115, 'TD': 0, 'INT': 1}
}
print("2012 quaterback statistics: ")
print("Passes completed: ")
for qb in quaterback_stats.keys():
print(f"{quaterback_stats[qb]} : {quaterback_stats[qb]['COMP']}")
print("Passing yards:")
for qb in quaterback_stats.keys():
print(f"{quaterback_stats[qb]} : {quaterback_stats[qb]['YDS']}")
print("Touchdown / interception ratio")
for qb in quaterback_stats.keys():
if quaterback_stats[qb]['TD'] > 0 and quaterback_stats[qb]['INT'] > 0:
print(f"{quaterback_stats[qb]} : {float(quaterback_stats[qb]['TD']) / float(quaterback_stats[qb]['INT])}")
else:
print(f"{quaterback_stats[qb]} : {0.0}")
Explanation:
The python program gets data from a dictionary called quaterback_stats which holds the data of football players with their names as the keys and a list of records as the value.
The program prints the individual records from the dictionary using a for loop statement on the list of dictionary keys (using the keys() method).
We value your presence here. Keep sharing knowledge and helping others find the answers they need. This community is the perfect place to learn together. IDNLearn.com is your source for precise answers. Thank you for visiting, and we look forward to helping you again soon.