Monday, December 28, 2020

PyBites: Python in Everyday Life

I've been learning Python for 6 to 7 months now, and have really enjoyed it. Slowly but surely, I am finding ways to incorporate what I have learned in Python and other things such as Git, terminal usage, etc., into my every day life.

The most recent example came when I was helping my daughter with her homework!

My daughter had a homework assignment called Magic Squares. If you are not familiar with them, a Magic Square is typically a three by three grid (similar to Tic-Tac-Toe), in which each of the directional rows or columns (vertical, horizontal, and diagonal) all have the same sum.

Due in part to the pandemic, she was assigned to do this in Google Classroom via a Google Slide.

The slide was not well prepared, and it was very difficult to place her answers into the correct boxes.

Me being me, I thought, "hey, this is a GREAT opportunity to use Python!" I thought about this in part because I had already made a Tic-Tac-Toe game in the past, and I already had a sample grid ready.

All we had to do was populate it with the values from her homework assignment and then fill her answers into the empty squares. I was able to do this using some string manipulation, i.e. converting the strings into lists to make changes and then back to strings again.

Long story short, I ended up using my newfound knowledge of Python, Git, and terminal commands to quickly create a file for her, write to the file with her answers, and send it via email to her teacher. The code is here.

All of this was completed in about twenty to thirty minutes, and the majority of that time was spent fixing each grid to match the initial state of each problem that she had.

This is a small example of the usefulness of Python in everyday life, but it has come in handy in other situations as well, such as having to parse a Rich Text File full of baby shower invitees for my wife.

I love learning more about Python and developing/computer science in general, and I can honestly say that I would not know nearly as much as I currently do without the great Bites from PyBites. Thanks, Bob and Julian, for creating such a rich environment to learn in. Your expertise is greatly appreciated!

Keep calm and code in Python!

-- Jesse



from Planet Python
via read more

No comments:

Post a Comment

TestDriven.io: Working with Static and Media Files in Django

This article looks at how to work with static and media files in a Django project, locally and in production. from Planet Python via read...