← Back to list

Week 2 as an AI/ML fellow at GDGoC Attock

As in my previous article, you might have seen and you know by now that I am an AI/ML Fellow at GDGoC and this article is dedicated to the…

Abdullah Asif · 2025-03-24 12:55 · 0 claps · 4.0 min read
#data-science #artificial-intelligence #machine-learning #gdgoc #fellowship
Open on Medium ↗
Wiki topics: ML · Machine Learning AI · AI · General EDU · Education & Learning 🔬 · Science · General

Week 2 as an AI/ML fellow at GDGoC Attock

As in my previous article, you might have seen and you know by now that I am an AI/ML Fellow at GDGoC and this article is dedicated to the second week of the fellowship. Tasks are as follows:

Task1: Data Types and Functions:

The first task was about the basics of Python and was related to different data types which include Boolean, integers, float, and their respective use cases as well.

  • Booleans are the decision-makers — just True or False. I used them to check stuff, like “Is my work done?” (True = relax time!). They’re perfect for yes-or-no questions in code.
  • Integers (or ints) are whole numbers — no decimals, like 1, 10, or -5. They became my counters, tracking things like how many coffees I would drink in a day. Simple, reliable, and exact.
  • Floats are the chill ones with decimal points, like 3.14 or -2.75. They saved me when I split a restaurant bill. They’re for when life gets a bit imprecise.

It also gives an introduction to functions. They’re blocks of code you name and reuse, saving time and effort. You write it once — say

def greet_me():

— add some instructions, and call it whenever.

Task 2: Conditional Statements and Introduction to Lists:

The next task introduced me to conditional statements that let the Computer decide based on certain parameters if fulfilled. It works by setting a value or a limit which if reached, some code with execute.

if(battery_percentage < 10):
    print("Connect Charger")
elif(battery_percentage == 100):
    print("Remove Charger")
else:
    print("Do Nothing")

Lists are introduced afterward which according to me are most powerful. Because if they didn’t exist, you would have to create variables to store things.

stationery = ["pen", "notebook", "pencil", "eraser", "ruler"]

Try saving these without the help of lists. It would be hard unless you stored it in a dictionary or a tuple. 😁

Task 3: File Handling

This is where things started getting harder. In file Handling, I was taught how to interact with a .txt file, how to read write and append in a file.

Opening a File:

You use open() to get started. I think of it like cracking open a notebook. You tell Python the file name and mode: “r” for reading, “w” for writing (overwrites everything!), or “a” for appending (adds to the end).

Reading

To see what’s inside, use “r”. It’s like flipping open the pages:

with open("stuff.txt", "r") as file:     
    text = file.read()     
print("Here's what's in there:", text)

Writing

Writing with “w” is like starting fresh. It erases the old stuff and adds your new words:

with open("stuff.txt", "w") as file:     
    file.write("New plan: be awesome.\n")

The \n makes a new line so it doesn’t all smoosh together.

Appending:

Appending with “a” adds to the end without messing up what’s already there:

with open("stuff.txt", "a") as file:     
    file.write("Also, eat snacks.\n")

I used this to keep piling on ideas — like snacks I shouldn’t forget to buy.

Task 4: Exceptions

When I started coding more in Python, I noticed it’s not always smooth sailing — sometimes things crash! That’s where exceptions come in. They’re like little alarms that go off when something goes wrong, like trying to divide by zero or opening a file that doesn’t exist. Exception handling is how you calm those alarms and keep your program from giving up.

What’s an Exception?

An exception is Python’s way of saying, “Uh-oh, I can’t do that!” For example, if I write 5 / 0, it freaks out because dividing by zero is impossible. Or if I try to read “ghost.txt” that’s not there, it’s like, “Nope, can’t find it!” Those are exceptions popping up.

Handling Them:

To handle exceptions, you use try and except. It’s like telling Python, “Try this, but if it flops, don’t panic — do this instead.” Here’s how I got the hang of it:

try:     
    number = 5 / 0  # Oops, can't divide by zero! 
except ZeroDivisionError:     
    print("Hey, you can't divide by zero!")

When I ran this, instead of crashing, it just laughed at me with my message. ZeroDivisionError is the specific exception for that math goof-up.

Task 5: Handling Packages

When I started learning Python, I’d cram everything into one big file — like stuffing all my clothes into one drawer. It worked fine until my code grew, and then it was a mess! Debugging felt like hunting for a sock in a pile, and fixing one thing broke three others. But Week 2 of my coding journey flipped that chaos into something awesome. I built a little Task Manager, and it taught me how to organize code like a pro.

Why Splitting Code is a Game-Changer

At first, I thought splitting code into different files sounded like a hassle. Why not keep it all together? But after trying it, I’m hooked. For my Task Manager, I set it up like this:

  • main.py → Where users talk to the program.
  • tasks.py → Handles adding and removing tasks.
  • file_stuff.py → Saves and loads tasks from a file.
  • tasks.txt → Where tasks live when the program’s off.

Now, if something breaks, I know exactly where to look — no more digging through a giant mess!

Saving Tasks the Easy Way

One neat trick I learned was saving tasks to a file so they don’t vanish when I close the program. I made functions to:

  • Read the file → Shows my old tasks.
  • Write to the file → Keeps new tasks safe.
  • Make the file if it’s missing → No crashes on day one!

It’s like having a little notebook that never loses my notes, and I even added some error checks so it doesn’t freak out if something goes wrong.

Making Tasks Work Smoothly

I wrote separate functions for adding, deleting, and showing tasks — all in tasks.py. Keeping them apart means I can fix one without touching the others. It’s like having toy blocks: I can swap pieces without breaking the whole tower.

For more details, the Source code is Here


메타데이터
post_id
32ff47fc0907
slug
week-2-as-an-ai-ml-fellow-at-gdgoc-attock-32ff47fc0907
url
https://medium.com/@myself.abdullahasif/week-2-as-an-ai-ml-fellow-at-gdgoc-attock-32ff47fc0907
canonical_url
https://medium.com/@myself.abdullahasif/week-2-as-an-ai-ml-fellow-at-gdgoc-attock-32ff47fc0907
author_url
https://medium.com/@myself.abdullahasif
status
ok
fetched_at
2026-07-20 13:32:42