Python Tutorial: Mastering Data Structures, Loops & Functions (Beginner-Friendly Guide)

Python Tutorial: Mastering Data Structures, Loops & Functions (Beginner-Friendly Guide)

A complete guide to Python’s most important building blocks — from strings and data structures to loops and functions — explained step-by-step in Tamil.

Learning Python Shouldn’t Be Intimidating

If you’re just starting your programming journey, or preparing for a job interview, chances are you’ve already heard of Python. But many tutorials can feel overwhelming — especially if you're learning in English.

That’s why we created a practical Python tutorial series explained entirely in Tamil — helping learners build skills in a language they’re comfortable with.

📺 Watch the full tutorial video here: 🎥 Python Tutorial Part 2 in Tamil – Data Structures, Loops & Functions

1. Input, Output, and Arithmetic Operations

Explanation:

Python allows you to write programs that take input from users using the input() function and display results using the print() function. When working with numbers, Python supports basic arithmetic operators like:

  • + (Addition)
  • - (Subtraction)
  • * (Multiplication)
  • / (Division)
  • // (Floor Division)
  • % (Modulus)
  • ** (Exponentiation)

These are the foundation for all mathematical and logical operations in Python.

Example:

a = int(input("Enter value for A: "))

b = int(input("Enter value for B: "))

print("Addition:", a + b)

print("Subtraction:", a - b)

print("Multiplication:", a * b)

print("Division:", a / b)

print("Modulus:", a % b)

print("Exponentiation:", a ** b)

2. Comments in Python

Explanation:

Comments are used to describe the logic in your code without affecting execution. This is especially helpful in collaborative projects or when revisiting old code.

  • Single-line comments use #
  • Multi-line comments use triple quotes ''' ... ''' or """ ... """

Example:

# This is a single-line comment

''' 

This is a multi-line comment

explaining multiple lines of code.

'''

3. Strings: Indexing, Slicing & Formatting

Explanation:

Strings in Python are sequences of characters. You can access parts of a string using indexing and slicing. String formatting allows you to insert values into a string in a clean way.

Python also offers many built-in string methods like:

  • .upper(), .lower()
  • .replace()
  • .count()
  • .startswith(), .endswith()

Example:

message = "Welcome to Python"

print(message[0])          # Indexing

print(message[0:7])        # Slicing

print(f"Message: {message}")  # f-string formatting

print(message.upper())     # String method

4. Data Structures in Python

Explanation:

Python offers four main built-in data structures:

a) List

  • Ordered
  • Mutable (changeable)
  • Allows duplicates

Example:

fruits = ['apple', 'banana', 'cherry']

fruits.append('orange')

print(fruits)

b) Tuple

  • Ordered
  • Immutable
  • Allows duplicates

Example:

dimensions = (10, 20, 30)

print(dimensions[1])

c) Set

  • Unordered
  • Mutable
  • No duplicate values

Example:

unique_items = {1, 2, 3, 2}

print(unique_items)  # Output: {1, 2, 3}

d) Dictionary

  • Key-value pairs
  • Keys must be unique
  • Values can be any data type

Example:

student = {"name": "Arun", "score": 95}

print(student["name"])

5. Conditional Statements (if, elif, else)

Explanation:

Conditional statements allow your program to make decisions and perform different actions based on different inputs.

  • if: Executes block if condition is true
  • elif: Checks next condition if the previous one is false
  • else: Executes when none of the conditions are true

Example:

mark = 85

if mark >= 90:

    print("Grade: A")

elif mark >= 70:

    print("Grade: B")

else:

    print("Grade: C")

6. Loops – for and while

Explanation:

Loops are used to repeat a block of code multiple times.

  • for loop is used to iterate over sequences (like lists, ranges, strings).
  • while loop runs as long as the condition is true.

Example – for Loop:

for i in range(1, 6):

    print("Number:", i)

Example – while Loop:

count = 1

while count <= 5:

    print("Count:", count)

    count += 1

7. Control Flow – break, continue, pass

Explanation:

These statements modify the flow of a loop:

  • break: Exits the loop completely
  • continue: Skips the current iteration
  • pass: Does nothing (placeholder for future code)

Example:

for i in range(5):

    if i == 2:

        continue

    print(i)

8. Functions in Python

Explanation:

Functions are reusable blocks of code that perform a specific task.

  • Use def to define a function
  • Use return to send back a result
  • You can use parameters and arguments to pass data

You’ll also learn:

  • Default arguments
  • Keyword arguments
  • Arbitrary arguments using *args

Example:

def greet(name="Guest"):

    return f"Hello, {name}!"

print(greet("Meena"))

9. Built-in Functions and Math Module

Explanation:

Python includes many built-in functions like len(), input(), print(), type().

The math module provides additional functions for:

  • Square root
  • Power
  • Floor (rounding down)

Example:

import math

print(math.sqrt(25))  # Output: 5.0

10. Recursive Functions

Explanation:

A recursive function is a function that calls itself to solve smaller parts of a problem.

Used for:

  • Factorials
  • Fibonacci sequence
  • Tree traversal

Example:

def factorial(n):

    if n == 1:

        return 1

    return n * factorial(n - 1)

print(factorial(5))  # Output: 120

11. Lambda Functions (Anonymous Functions)

Explanation:

Lambda functions are small, one-line functions used when you don’t want to formally define a function using def.

Used with:

  • map()
  • filter()
  • reduce()

Example:

square = lambda x: x * x

print(square(4))  # Output: 16

👨🏫 Who Should Learn from This?

  • Beginners learning Python for the first time
  • Students preparing for IT interviews
  • Freshers aiming for placement in software companies
  • Tamil-speaking learners who want native-language guidance

🎥 Need more guidance or want to see it all in action? Watch our full hands-on session (in Tamil) with real-time explanations here: 👉 Watch Now – Python Tutorial Part 2: Data Structures, Loops & Functions

💬 Have questions? Comment here or reach out directly — I’m happy to help!

📌 Want to master more Python topics like OOP, file handling, and exception management? Follow this page to stay updated with our next tutorial drops.

👉 Start today. Practice every day. Grow your coding career with confidence.

🎥 Watch the full tutorial here (in Tamil): 👉 https://www.youtube.com/watch?v=UeBScmkPi1k&list=PL4mhU4NOxr72vxan5RMPu2c-HK29hqQZV&index=3 📺 Subscribe to our YouTube channel for more tutorials like this: 👉 https://www.youtube.com/@SLAOfficial This is Part 3 of our Python series — covering Data Structures, Loops, and Functions with real-time examples and simple Tamil explanations. Perfect for beginners, freshers, and job seekers. Happy Learning! 💻✨

Like
Reply

To view or add a comment, sign in

More articles by SLA Institute

Others also viewed

Explore content categories