Category: Blog
-

Automating Tasks in Python: Snake Game Improvements and the Mail Merge Project
Today, I made some exciting progress in two areas: enhancing my Snake Game and completing a new project called Mail Merge. Both projects taught me important concepts such as: file handling in Python, and working with directories and paths. Here’s a wrap-up of what I learned, the improvements I made, and how Python’s file handling…
-

Wrap-Up: Lessons Learned from Building the Turtle Crossing Game
After several weeks of development, I’m excited to share the final wrap-up of my Turtle Crossing game project. This journey has been both challenging and rewarding, offering me new insights into Python programming, particularly in the areas of object-oriented design, the use of the self keyword, and practical implementations like the enumerate() function. Here’s a…
-

Project Update: Leveraging enumerate() in Python for Turtle Crossing
As I continue working on my Turtle Crossing project, I encountered a challenge that led me to explore new Python functions. Initially, I was experimenting with different alternatives for the number of cars generated in the game. I wasn’t satisfied with generating a random number of cars; I wanted a specific number to cross the…
-

Understanding self in Python Classes: A Deep Dive with Turtle Crossing
Understanding self in Python Classes: A Deep Dive with Turtle Crossing When developing a game or any object-oriented Python program, understanding how to manage class instances is crucial. This is where the concept of self comes into play. Recently, while working on my Turtle Crossing game, I encountered a challenge that highlighted the importance of…
-

Understanding Inheritance and Boilerplate in Python Projects
While writing some lines of code for a project I am working on called PONG, I got confused about when to use the inheritance approach. Initially, I created an object using a class and then recalled it to add attributes or methods. This method seemed to work, but I noticed something interesting when I compared…
-

The Importance of Attribute Order in Class Initialization
When writing code for a game called Snake, I encountered an error while trying to run the program. Here’s the error message: Understanding the Error This error occurs because the create_snake method is attempting to use the self.x attribute before it has been initialized. Let’s examine the problematic code: In the above code, self.create_snake() is…
-

Effortlessly Extract and Print Dictionary Items with Units in Python
Extracting and printing specific items from a dictionary in Python could be a nightmare. You may want to print only the values or keys. Maybe you want to print both in one report or what could you do if you are adding additional information such as units? Let’s say you have a dictionary with a…
-

Efficiently Picking Random Elements in Python: randint vs. choice
If you have a list and you want to randomly choose an element from that list you can use, as I did, a complex or easy way. Maybe you have a list with a nested dictionary with a celebrity’s name, number of followers, career, and country of origin. One way to do this is by…
-

Mastering Control Flow: Using While Loops and Conditionals to Meet Specific Conditions
Within the logic of the Blackjack game, there is a condition that must be met. After the user picks his cards, it is time for the computer to play. The computer has to ask for a card when the sum of its deck is less than 16. The original logic was: Input: Output: computer’s final…
