python program to make a fantasy football team using stats

Extra Credit- Fantasy Football

Who is ready for some football?

Your fantasy football draft is coming up and you are definetly going to win this year. You’ve got an edge on your oppentents this year: you have a super accurate forecast to how players are going to peform this year and you have your coding skills!

Your league has the following rules:

You must select

– One quarterback

– Two running backs

– Two wide receivers

– One tight end

– One flex player (either a RB, a WR, or a TE)

In players.txt, there is a text file with the forecast for each player. Each player has their expected stats. It is formatted as follows:

Position Name PassingYards PassingTDs RushingYds RushingTDs ReceivingYds ReceivingTDs

Your job is to create the best team from the listed players using the following scoring:

You receive 1 point for each 25 yards of passing

Each passing TD is worth 4 points

You receive 1 point for each 10 yards of rushing

Each rushing TD is worth 6 points

You receive 1 point for each 10 yards of receiving

Each receiving TD is worth 6 points

Your code should output each position, each player, plus how many points they are expected to score, as such:

QB Mahomes 442

RB1 Gurley 309

RB2 Barkeley 292

WR1 Hill 244

WR2 Hopkins 223

FLEX Elliott 254

To learn more about how to read files in Python, you can read this documentation. You will also need to read up on how to use the split function in Python.


You can earn 20% extra credit by passing all of the test cases for this question.

Here is an example players.txt file you can use.

players.txt :…