Welcome to the Pathetic Programming series where I intend to build programs with some silly and stupid goals. The idea was just to have fun with programming, not think much about efficiency and those warnings (as if we ever cared!), and code for some pathetic solutions that one would hardly need in the first place. So let us start with the very first exercise of Pathetic Programming series: Creating a Random Excuse Generator with Python.
There are often times when I do not want attend a boring meeting and rather do some productive work, or avoid any party because I want to lay in my couch and watch Formula 1:Drive To Survive (hardcore Goatifi fan here btw!) on Netflix. So I thought, “Hey, there are thousands are people out there like me who might share the same feeling, so why not build an excuse generator and provide my social service!” So my fellow readers, grab your coffee and let us get ready to lie.
Table of Contents
Machine learning models improve with more data. Your feed improves with more of my posts. Follow @machinelearningsite for programming memes, code snippets, and ML tricks—no overfitting, just pure value.
How It Works
This isn’t just any excuse generator—it’s a pathetically perfect one. With a simple click, it generates random excuses that are totally believable. Here’s what makes this tool a real lifesaver:
DIY Mode: Got a killer excuse of your own? Add it to the mix and watch it join the ranks of dodging excellence.
Excuse Database: Packed with excuses for every scenario, from “Got COVID” to “Family emergency came up.”
Random Roulette: Hit the generate button, and voilà! A new excuse pops up every time, keeping your alibis fresh.
The Pathetic Program
For the brave (and lazy) souls ready to dive in, here’s a peek at the Python script behind the scenes:
import random
import pandas as pd
class ExcuseGenerator:
def __init__(self, excuses):
self.excuses_data = excuses
def generate_excuse(self, question):
# getting excuse from the csv data
excuse = self.excuses_data.iloc[random.randint(0, self.excuses_data.shape[0]-1),question-1]
return excuse
def add_excuse(self, new_excuse, scenario_index):
# Append new excuse to the existing database
new_row = pd.DataFrame([[None] * self.excuses_data.shape[1]], columns=self.excuses_data.columns)
new_row.iloc[0, scenario_index - 1] = new_excuse
self.excuses_data = pd.concat([self.excuses_data, new_row], ignore_index=True)
# Save the updated DataFrame back to the CSV
self.excuses_data.to_csv("1_random_excuse_generator/excuses.csv", index=False)
def main():
excuses = pd.read_csv("1_random_excuse_generator/excuses.csv")
excuse_generator = ExcuseGenerator(excuses=excuses)
while True:
action = input("Do you want to generate or add an excuse? Select the number:\n1. Generate\n2. Add\n")
if action == '1':
question = input("Is it to avoid work or socializing? Select the number:\n1. Work\n2. Socializing:\n")
try:
question = int(question)
print("\n"+ excuse_generator.generate_excuse(question)+"\n")
except ValueError:
print("Please enter an integer value.\n")
elif action == '2':
new_excuse = input("Enter your new excuse: ")
scenario = input("Is this excuse for work or socializing? Select the number:\n1. Work\n2. Socializing:\n")
try:
scenario = int(scenario)
excuse_generator.add_excuse(new_excuse, scenario)
print("Excuse added successfully.")
except ValueError:
print("Please enter an integer value.\n")
else:
print("Invalid option, please select 1 or 2.\n")
if __name__ == "__main__":
main()
Here’s the link to my GitHub account where you will find the CSV file. Whether you’re dodging work or a family dinner, this generator’s got your back. Here are a few excuses you’ll love:
- Feeling Unwell: “Sorry, I can’t make it, got food poisoning!”
- Emergency: “I’m dealing with a family emergency, can’t attend!”
- Boss called you up: “My boss suddenly needs me on-call this eve.”
Summary
Now you know how to get out of situations that you want to avoid. You think you are the most believable excuse maker? Feel free to add a few of them in the database. Share screenshots of those excuses on Instagram and do not forget to tag me @machinelearningsite. 😉
Wait, there’s more! How about creating an app out of this and making it available to the rest of the world? Have a look at Deploy your own Python app Easily using *THIS*! to know how you can make your pathetic Python program available to billions of people out there.
Share this with your friends who keep making excuses to bail out of everything, or maybe send to those who need to this. Don’t forget to follow me on Instagram to stay updated with the latest posts.