Soccer Formation

Hello!

This is just a mini blog post about my Soccer Formation assignment in Programming. It was started on 11/6, but I was out in Pennsylvania visiting Bucknell, Lehigh, and Lafayette. I started today (11/9), and finished it today. It was to create a soccer field and its 11 players, with their numbers and their soccer positions. An additional task was to randomly generate which players had yellow or red cards.

Here is the link to the instructions: http://www.101computing.net/football-formation/
Here is the link to my code: https://trinket.io/python/0813ea96f6

This project was a lot easier than other ones because half of the coding was done given. I then just had to copy the concepts that were already written, and replicate them for the rest of the players on the team. I did have to understand the concept of 'parameters', because I needed to add a parameter for the yellow/red cards. Another concept that was further emphasized in this activity was using coordinates, because you had to space out all the players. Lastly, I learned how to change the 'drawPlayer' function, to make the player's position be printed below the circle. I also made the radius of the circle a bit larger.

For the yellow and red cards, I had it so that when creating each player, it was assigned a random integer from 1-6, and if 1 is chosen, that player has a red card (thus their number is red), and if 2 is chosen, that player has a yellow card (thus their number is yellow). If any other number (used else:) is chosen, then that player does not have any cards, so their number is black. By doing this, every time that the code is loaded, everything will be randomized once again. 

This activity was from 101Computing, which we will be doing more projects from as the semester continues. Our next activity is a penalty shootout.

Until next time!
Mimi

Comments