Exploring Python Fundamentals in Data Science
A Week of Learning and Building

My first week in the DataraFlow Internship has been refreshing and insightful. I got the chance to revisit some core python concepts and see more clearly how python ties everything together in the data science process.
What I Learnt
I spent time revisiting some core python concepts that serve as the foundation for data analysis and engineering work:
Data Types & Structures: Understanding Lists, Tuples, Sets, and Dictionaries
Lists: List is a series of values, declared using square brackets '[ ]'. A mutable collection that allows duplicate elements.
It is suited for storing sequences of items where frequent updates (additions, deletions) are needed.
Example: A list of fruits:
# A list of fruitsfruits = ['apple', 'banana', 'orange', 'pineapple']
Tuples: A tuple is a sequence of python objects separated by commas. An immutable collection that can contain duplicate elements. Tuples cannot be modified after created and are mostly used for a fixed collection of data. Tuples are declared using brackets ‘( )’.
Example: Coordinate points
# Coordinate point x and yx = (3.0, 4.0)y = (6.0, 8.0)
Sets: Set is an unordered collection of unique items, values separated by a comma inside curly braces ‘{}’. Sets automatically eliminate duplicates. It allows quick checks for element presence and effective for mathematical set operations such as union or intersection.
Example: Let’s create set of fruit types
# Create setsfruits = {'apple', 'banana', 'cherry'}berries = {'strawberry', 'blueberry', 'raspberry', 'cherry'}
Notice how python set automatically returned just one ‘cherry‘.
Dictionaries: I learnt dictionaries are the most flexible built-in data type in python. It is a collection of key-value pairs, where keys are like unique identifiers and map directly to values (which are like data representing each key). Just like set, dictionaries are enclosed in curly braces '{ }'.
Example: Here's an example of using dictionaries with fruit categories as keys and fruits that belong to each category as values:
# A dictionary with fruit types as keysfruit_types = { 'Citrus': ['orange', 'lemon', 'lime'], 'Tropical': ['mango', 'pineapple', 'papaya'], 'Berries': ['strawberry', 'blueberry', 'raspberry'], 'Pome': ['Apple', 'Pear'] }
Take away: Lists and tuples are best when order matters. Sets are best when uniqueness is required. Dictionaries are best when mapping or quick lookup is needed or there is a need to convert data to a dataframe.
Functions in Python: Functions are used to write reusable code in python, they perform repeated tasks efficiently.
A function is a block of code which only runs when it is called. It accepts data, known as parameters. It is mostly used to prevent writing the same line of code multiple times, a function enables wrapping a task into a single definition that can be executed whenever needed.

Loops: for loop and while loop
Loops allow us to repeat a block of code without writing it multiple times.
for loop: Iterates over a sequence (list, tuple, string, range, etc.) or any other iterable objects.while loop: Iterates over a block of code and repeats as long as the condition is True.
Conditionals ( if, elif & else statements)
The if, elif & else statement is used in Python for decision making. It enable decision making by executing specific blocks of code when conditions are met.

What I Built
So… as part of applying the concepts, I worked on a set of mini-projects.
Multiplication Table Generator: An Iterative program that displays multiplication table from 1–12.

Factorial Calculator: calculates the factorial of any integer using loops.

Simple Calculator: Performs operation on two numbers.

Student Grades System: Accepts grades in various subjects, sums it up and return the average.

Guessing game: Accepts an integer, if it’s the same with the secret number, you win!

Shopping cart: A program where a user can add items to a shopping cart, input item names and prices, then display the total cost.

Challenges Faced & Solutions
At first, I got errors like TypeError: 'str' object is not callable.
Solution: I learned that this usually happens when you name a variable the same as a built-in function (e.g., naming a variable str). Renaming the variable fixed the issue.
I got confused around using return & print inside a loop.
Solution: I realized that return gives back a value for reuse in code, while print just displays it immediately. Now I know when to use each appropriately.
Conclusion
This week has been both a refresher and an eye-opener. Revisiting python basics while applying them to hands on exercises has increased my confidence in writing clean, functional code. Each mini-project strengthened my logical reasoning and I believe it is to get prepared for the bigger projects in the coming weeks.
I’m looking forward to expanding beyond the basics.

