DEV Community

spinner77
spinner77

Posted on

My first Python Program: Tarot

Introduction:
My career path has been quite the rollercoaster ride! I’ve hopped from job to job, ranging from serving up pints as a barmaid to providing medical care as a nurse. My friends and family like to tease me about my tendency to switch things up, but I can't help but embrace the journey!
So, it's no shocker that I'm now diving headfirst into the world of computer science through Codeacademy and CS50. Sure, some might say it's a far cry from giving I.V.'s to writing code, but for me, chasing knowledge and learning has always been my lifelong passion.
If curiosity calls, you’ll find me eagerly diving into a new subject. Lately, I've been itching to unravel the wonders of computers and harness their power to make life more awesome for myself and others.
For my first project, I've decided to keep things simple (but equally enchanting!) by creating a Python program for my portfolio. Being a curious soul, I've always been captivated by the mystic charm of tarot cards ever since I was a little girl, rummaging through my dad's fascinating book on fortune-telling.
Now, I’ve taken my love for the enchanting art of tarot reading and combined it with my newfound passion for coding. I've crafted a program that dishes out a "three-card spread," which delves into your past, present, and future. The result? A delightful mix of technology and mystical charm!
While I may approach fortune-telling with a mountain of salt these days, I can't deny the fun memories of giving readings to my friends back in the day. It's only fitting that my first "how does this work?" fascination fuels my maiden voyage into the world of coding.
Background Info:
Tarot cards have been used for centuries as a tool for divination and self-reflection. Each card represents a different archetype or life lesson, offering guidance and perspective on various aspects of one's life. My goal in creating this program was to provide users with an accessible and engaging way to delve into the world of tarot and use it as a means of personal growth.
Program Overview:

A snapshot of my code in VSC, showing the ascii art

My Python program generates a three-card tarot reading, providing users with insights into their past, present, and future. Each card is selected at random from a list of only the major arcana tarot cards, and the program includes detailed descriptions of the upright and reversed meanings for each card.
The Python Code:
To create this program, I utilized Python’s built-in libraries, like random, to select cards at random from a list. Each card is represented as an instance of a custom-defined Card class, which includes the card's name, upright meaning, and reversed meaning. I've organized my code into functions for shuffling, drawing cards, and printing card meanings, making the program easy to read and maintain.
You can find the entire codebase on my GitHub
Conclusion:
Working on this Python-meets-tarot project has been a fun ride! I got to play around with Python's built-in libraries and found some cool ways to spice up my code. I also dipped my toes into the world of ASCII art and learned how to create Classes and methods to make the most of their capabilities.
My Codeacademy lessons were a huge help, and I found some great resources on python.org too. As I keep learning and growing, I'd love to hear your thoughts on my project. Feel free to share your feedback – it's always appreciated and helps me become a better coder for future projects!

Top comments (0)