Learning from my past...
Tags: python, beginners, programming
Published: 2022-10-26 20:19:23

So,
This here is my first post. I thought I'd never create a blog, but better late than ever. A year or so ago I decided to change careers. I used to be a 3D Artist, got my degree in the US, but didn't have much luck when I moved back home Rio, Brazil.

Anyways, 
First, I tried a data scientists specialization throhgh coursera. Did it, but I felt like I just watched classes for the sake of getting the degree. 

Second, since I thought I've learned the basics of python through that course, I decided to go adventure myself in Udemy. Started with a Django Course - By Dennis Ivy. Great course if you have any idea of CSS or HTML. But I didn't.

Since then, I've wached a few other courses. Started with "ProgramadorBr", great for HTML, CSS and the basics of javascript. But it really lacked on the React side, since was still teaching class components.

Then I found out about Brad Traversy. Great teacher for follow along projecs and a master of express js api. But with time I felt like I was circulating around a lot the same topics but never getting any deeper. That was about the time I decided to give RocketSeat a trie. They really go deep into the meet and potatos of NextJS on the React track and give you a great base for S.O.L.I.D. on the Backend track with Node. Still, I felt like I was just digging, deeper, and deeper into the rabbit hole.

So, the API I was building for work wasn't going to be used since they decided to use an Insurance CRM. I decided to take another try on Python. Finally, took the leep of faith and enrolled on the CodeCademy in the CS Career Path and I'm happy to say it feels like the best choice I've made in a while.

This is my first Final Project for the CS101 class.
During the class one of the assigments was to create a tarot card game. I decided to take the game a sep futher and fetch from a real API and actually read your fortune from the terminal. 


First I found a tarot API:
```python
url = "https://rws-cards-api.herokuapp.com/api/v1/cards"
response = requests.get(url)
response_json = response.json()
cards_to_iterate = response_json['cards']
```

then I created a Card class:
``` python
class Card:
    def __init__(self, value, name, meaning_up, meaning_rev):
        self.value = value
        self.name = name
        self.meaning_up = meaning_up
        self.meaning_rev = meaning_rev

```

looped and stord everycard and initialized my picked cards:
```python
cards = []
for card in cards_to_iterate:
    cards.append(Card(card['value'], card['name'],
                 card['meaning_up'], card['meaning_rev']))

picked_cards = []

```

created my functions to pick my cards:
```python
def pick_card():
    card = random.choice(cards)
    if card in picked_cards:
        pick_card()
    else:
        picked_cards.append(card)
        return card


def pick_side():
    return random.choice(['up', 'rev'])
```

wrote the main function that will run the game:

```python
def main():
    # Program must interact with user
    # Program will greet the user
    print("Hello, I am the Tarot Card Reader. I will read your cards for you.")

    # Program will start with the user's name
    name = input("What is your name? ")

    # Program will ask the user if they want a reading
    time.sleep(1)
    reading = input("Would you like a reading? yes or no? ")
    if reading == "yes":
        print("Ok, I will read your cards.\n")
    else:
        print("Ok, maybe next time.")
        exit()

    # Program will shuffle the deck
    print("Shuffling the deck...\n")
    time.sleep(1)

    # Program will pick 3 cards
    print("Picking 3 cards...\n")
    time.sleep(1)

    # Program will pick the first card
    card1 = pick_card()
    side1 = pick_side()

    # Program will pick the second card
    card2 = pick_card()
    side2 = pick_side()

    # Program will pick the third card
    card3 = pick_card()
    side3 = pick_side()

    # Program will start the reading
    print("Ok, here is your reading.\n")
    time.sleep(1)

    # Program will print the first card
    print("Let's start with your past.")
    time.sleep(3)
    meaning_1 = card1.meaning_up if side1 == 'up' else card1.meaning_rev
    side_option_1 = "up" if side1 == 'up' else "reversed"
    print("The first card is the {card1.name} card. It is {side_option_1}.".format(
        card1=card1, side_option_1=side_option_1))
    # The meaning of the card
    time.sleep(1)
    print("The meaning of the card is {meaning_1}.\n".format(
        meaning_1=meaning_1))

    # Program will print the second card
    print("Let's move on to your present.")
    time.sleep(3)
    meaning_2 = card2.meaning_up if side2 == 'up' else card2.meaning_rev
    side_option_2 = "up" if side2 == 'up' else "reversed"
    print("The second card is the {card2.name} card. It is {side_option_2}.".format(
        card2=card2, side_option_2=side_option_2))
    # The meaning of the card
    time.sleep(1)
    print("The meaning of the card is {meaning_2}.\n".format(
        meaning_2=meaning_2))

    time.sleep(3)

    # Program will print the third card
    print("Let's finish with your future.")
    time.sleep(1)
    meaning_3 = card3.meaning_up if side3 == 'up' else card3.meaning_rev
    side_option_3 = "up" if side3 == 'up' else "reversed"
    print("The third card is the {card3.name} card. It is {side_option_3}.".format(
        card3=card3, side_option_3=side_option_3))
    # The meaning of the card
    time.sleep(1)
    print("The meaning of the card is {meaning_3}.\n\n".format(
        meaning_3=meaning_3))
    time.sleep(3)

    # Program will thank the user
    print("Thank you for your time. I hope you enjoyed your reading.")

```

And later called it.
I Thought it was a pretty neat projet to make and only took me around 30 minutes. Thank you for your time.



Almost forgot you can find the project on the following repo:
[](https://github.com/wrath-codes/portfolio-project
)