DEV Community

Kevoh Mungai
Kevoh Mungai

Posted on

Python 101 on Data Analytics

If you are also starting out in data analytics, let me tell you something: Python can look intimidating at first, but once you start writing small pieces of code and seeing them work, it becomes much less scary. I didn't begin with complicated data science models or massive datasets. I started with the basics—printing things, taking inputs, doing calculations, and understanding how Python treats different types of data.

So, what exactly is Python?

Think of Python as a language you use to communicate with your computer.

You tell the computer what you want it to do, and Python translates those instructions into something the computer can execute.

One of the first things I played around with was simple arithmetic.

For example, I wanted Python to add 14 + 15 + 16.

print(14 + 15 + 16)
Enter fullscreen mode Exit fullscreen mode

And Python gives you:

45

As a data analyst, you will constantly be asking a computer to calculate totals, averages, percentages, differences and other measurements. Python allows you to automate those calculations instead of doing everything manually.

Then I started working with variables

The next step was understanding how Python stores information.

Instead of writing the numbers directly inside print(), you can put them into variables.

For example:

num1 = 14
num2 = 15
num3 = 16
print(num1 + num2 + num3)

the answer is still 45

_But now we have done something more useful.

We have given each piece of information a name._

That's a big part of programming and data analytics. You don't just have numbers—you have data stored in variables that you can manipulate.

Then came user input

One of the things I was practicing was getting Python to ask the user for information.

For example:

name = input("Enter your name: ")
print("Hello", name)

If I type:

Kevin

Python responds:

Hello Kevin

This might seem basic, but it teaches an important concept: data can come from outside the program.

In a real data analytics project, your data might come from an Excel spreadsheet, CSV file, database, API or another system.

The source changes, but the basic idea remains the same: Python receives data and then does something with it.

I also learned that Python cares about data types

This was one of those small things that can easily confuse a beginner.

For example, Python can work with different types of data:

_

_

And that distinction matters.

For example, if Python gives you a number as a float:

number = 10.8

and you want to convert it into an integer, you can use:

number = int(10.8)
print(number)

**The result is:

10**

**

This introduced me to type conversion.

**
In data analytics, this becomes extremely important because datasets are often messy. You might receive a column that looks like numbers but is actually stored as text.

Before performing calculations, you may need to convert that data into the appropriate format.

Then I started putting input and calculations together

Here's where the simple exercises started becoming more interesting.

Suppose I want the user to enter three numbers and have Python calculate their total.

I can write:

`num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
num3 = int(input("Enter third number: "))

total = num1 + num2 + num3

print("The total is:", total)`

Now Python isn't simply calculating numbers that I have already entered into the code. It is receiving data, converting it, processing it and producing an output. And if you think about it, that's already the foundation of a very simple data-processing pipeline.

Input → Processing → Output.

The small mistakes are actually part of learning

One thing I have discovered while learning Python is that you will make mistakes.

_

  • A missing quotation mark.
  • A bracket in the wrong place.
  • Using the wrong variable name.
  • Forgetting that input() normally returns text. _

At first, an error message can look like Python is speaking another language.

But I'm slowly learning to read those errors instead of being intimidated by them.

For example, this:

age = input("Enter your age: ")

stores the answer as text.

If I want to use the age as a number, I can instead write:

age = int(input("Enter your age: "))

That tiny int() makes a big difference.
Enter fullscreen mode Exit fullscreen mode

Why does all this matter for data analytics?

You might be wondering: "Kevin, these are very basic examples. What do they have to do with data analytics?"

A lot, actually.

Data analytics is essentially about taking data and turning it into useful information.

_Python gives you tools to do that at scale.
_
Imagine moving from:

num1 = 14
num2 = 15
num3 = 16

to a dataset containing 100,000 sales transactions.

Instead of manually calculating everything, Python can help you clean the data, calculate metrics, identify patterns and eventually create visualizations.

That's where libraries such as Pandas, NumPy and Matplotlib become important.

But before getting there, you need to understand the fundamentals.

_- Variables.

  • Data types.
  • Inputs.
  • Outputs.
  • Calculations.
  • Functions.
  • Conditions.
  • Loops.
  • Data structures._

*These may look like small building blocks, but they eventually become the foundation for much more advanced analytics.
*

My biggest lesson so far

If you're learning Python for data analytics, don't rush straight into complicated projects.

Start small.

Write:

print(14 + 15 + 16)

Then ask yourself:

What if those numbers were stored in variables?

Then:

What if the user entered them?

Then:

What if I had 100 numbers?

Then:

What if those numbers came from an Excel file?

Then:
What if I wanted to calculate the average, find the highest value, identify trends and create a chart?

That progression is where Python starts becoming really powerful.

And that's basically where my own Python journey has been heading over the last few weeks.

I started by asking Python to do something as simple as adding 14 + 15 + 16.

Now I'm beginning to see that those little exercises weren't just random beginner questions.

They were teaching me how to think like a programmer—and, eventually, how to use Python as a tool for data analytics.

Python 101 has officially begun.

Top comments (0)