DEV Community


Posted on

Codecademy CS101 Final Project: Electric 7's

Alt Text


I've been taking the Computer Science course on Codecademy for a little over a month and the final project for the 101 course is to create a terminal game using python. Originally I was going to create a text based adventure game, but after a night with some friends where we wanted to play a game but lacked the cards required to play, decided that this would be a more useful way to spend my time. I'm happy I made the change since this required me to think outside the box a few times to figure how to make the game work.


The program takes in the number of players, using this information to to later split the deck between players. The deck is created by iterating through 1-13 and each suit, adding the two together to make each card. Once this is accomplished the 7's are removed and the remaining cards are shuffled and dealt to a variable to represent each players hand.

In order to iterate through the players, I created a play function that adds one to itself after each turn taken until the count reaches 48, the number of cards left in the deck after removing the 7's. The program then begins running through the play function, which prints the current cards that have already been played and the players hand. The player is prompted to pick a card to add to the playing field. Depending on the input, the program decides if the player gives or takes drinks as well as how many based on the range of cards in that suit. This is then repeated for each player until the game is complete and the program ends.

If you would like to try it out or look at the code, the github repo is here

Possible Refactoring

I would possibly like to go back and retry making this program using object oriented programing. I feel like the code was slightly long for what the program does and feel like OOP may help reduce the size of the code.

Discussion (0)