python fundamentals

A Beginner's Guide for Python Fundamentals —- — Variables, Comments, Data Types.

M Dhanunjaya
4 min readDec 10, 2022

--

Scope of article: Understanding variables, different data types in Python from scratch, how to assign data to variables, and finally how to use comments with some examples

Variables: To understand variables better in Python, we can consider variables to be like some containers in our house that we use to store sugar or coffee powder or something. From the above example, container 1 is filled with coffee powder, and container 2 is filled with dal. When the coffee powder and dal are finished, the two containers are ready to be filled with something, whether it is the same or a different substance.

containers compared with variables

In a similar way, the variables are designed in Python.

Now let’s discuss some data types:

What does the term “data type” actually mean?

The name itself suggests that data comes in different forms. So how many types of data we actually have?

  • Data in numbers format [1234]
  • Data in numbers form along with decimal numbers format [12.334]
  • Data in text format [dj]
  • Data in mixed format [dj1234.7899]
  • Data in complex format [2+9j]

So as humans, we can understand the basic difference between these data forms, but how can we correlate these things and tell the computer to understand the difference between them when they are given?

To solve the given problem statement, they came up with a solution called “DATA-TYPES”

These data types are classified in different formats:

  1. Integer type
  2. String type
  3. Float type
  4. Complex type

Integer type:

It means only numbers are given in this format like 2378868797908

Float type:

It means the numbers are given along with the decimal part attached to them like 2398789.098

Complex type:

It means the numbers are given in their complex and real part, like 6+9j. In the imaginary part, we only used j.

String type :

It means the decimals, text, integers, and complex parts are all mixed in this type.

But how ?

It is possible with the symbol single quotation or double quotation marks “,” or ‘,’ . The format is like ‘apple is 2+2’ or “20898.8686+7+3j and my name is dj”

Now we have to know about the assignment operator. What it means?

Add alt text

We generally use it in mathematics, especially in algebra, like a=2x like this here the = is called as assignment operator.

Before we move further we need to know about some naming convections for variables: only some 🙂

1.Never start the variable name with a number or with space

2. Don’t use any space or any special characters in the variable

Examples:

#rule 142apple 3aplle#rule 2:apple-is-mineaplle@is#min%apple!@#$%^&*()-={}":>?<>?

Comments :

What actually comments means?

These comments are like some headings for the coding we write .

Why these comments are essential?

These are essential when we write a code and give to someone , how they can understand what each line represents in your code. For suppose you have written some n no. of lines of code and how you can track each line of code. So the smarter way is to use comments in your code. we can insert comments in your code by using the hash #symbol before the code. For multiline comment you can use ‘‘‘ ’’’. Single quotation three times.

#commentsingleline

"""
multiline
comment
"""

Now let's combine everything and practice in real time.

Download Jupiter notebook from here :

Summary

Variables , Comments and Data Types are Designed in python for specific purpose based on the need. Understanding these fundamentals are very curial at beginning stage. Give Yourself enough amount of time to adapt yourself.

Happy Learning!!!

👍😊🙂🙂😊😊🙂😊🙂👍

For more articles on Data Science visit my Medium profile.

About the Author: I am Dhanunjaya, A Data Science Enthusiast. I’m currently learning Full Stack Data Science at Ineuron.ai and If you have any questions please connect with me on my Linkedin profile.

Connect via Social Media Platforms :

INSTAGRAM, YOUTUBE, Linkedin , Medium , Twitter

--

--

M Dhanunjaya

If You Can't Do Everything, Then do everything You Can Do