Day 25 - US States Game + Movie List

Day 25 - US States Game + Movie List

Getting a better understanding of Pandas Library


3 min read

Let's start with the boring stuff

Today I completed Day-25 of my 100 Days of Python journey. The challenge? To deepen my understanding of Pandas through a project that, honestly, wasn't the most thrilling โ€“ a U.S. States guessing game. Sure, it sounds mundane, but it's crucial stuff, especially since handling CSV files with Pandas is a fundamental skill in the world of finance apps. So, let's dive in and break down this project, tedious as it might have been!

๐ŸŽจ The Toolbox: turtle & pandas

For this project, we only needed two libraries: turtle and pandas. Turtle is like the old reliable of Python teaching tools. It's great for learning Python basics through small, graphical projects.

And then there's pandas โ€“ the data wizard of Python. Think of it as your go-to tool for manipulating structured data like CSV files. In this project, pandas was the key to managing the game's data, from importing state info to exporting our "to-learn" list. ๐Ÿ“Š๐Ÿ“

๐Ÿ•น๏ธ Setting the Scene: The Game Screen

The first order of business was setting up our game screen, creating a new window titled "U.S. States Game" and decking it out with a background image of a blank U.S. map. The image is a .gif file since the turtle library only works with those files for use within its methods. For example:

pythonCopy code    image = "blank_states_img.gif"  

With these lines, we're utilizing turtle's addshape() and shape() functions to integrate our map into the game.

๐Ÿ“š Crunching Data with Pandas

Next, we harnessed the power of pandas to read a CSV file named "50_states.csv". This file was essentially the game's backbone, storing the names and coordinates of all U.S. states. We transformed this data into a list called all_states, setting us up for the game's logic. ๐Ÿ—บ๏ธ

๐ŸŽฎ The Gameplay: Guessing the States

This is where things got a tad more interesting. We started with an empty list, guessed_states, to track correct guesses. The game looped, prompting for state name guesses. Typing "Exit" would end the game and save a list of states still to be guessed into "states_to_learn.csv". A nice little feature to keep the challenge going! ๐Ÿ

โœ๏ธ Marking the Map: Displaying Guessed States

Every correct guess brought a new turtle onto the scene to mark the state's name on the map. Simple, yet effective. You can find the project here if you wanna check out the code -> Github Repo.

So, that wraps up Day-25. While the project didn't exactly set my world on fire, it did reinforce some key skills. But let's be real, my mind kept drifting to a more exciting project...

Teasing FanFlix

The working title? FanFlix. It's not set in stone, but the project itself is something I'm pretty pumped about. It's a CRUD app blending Svelte's sleekness with Django's robustness. I'm still chipping away at it, and I'll share more in a dedicated post once it's up and running. Stay tuned for a real-world example of Svelte and Django in harmony โ€“ something that's not too common out there.

๐Ÿ“ข Let's Connect!

Got any thoughts on Python, game coding, my main project, or just tech in general? Hit me up and lets chat!

Did you find this article valuable?

Support Kyle Leonard by becoming a sponsor. Any amount is appreciated!