Category: Python

  • Learn Python in Tamil | Python Basics | How to use Conditional Statements if ,elif, else

    More Examples :

    1. Basic if-else Statement:

    number = 10
    if number > 5:
     print("The number is greater than 5.")
    else:
     print("The number is 5 or less.")

    2. Multiple Conditions with elif:

    marks = 85
    if marks >= 90:
        print("Grade: A")
    elif marks >= 75:
        print("Grade: B")
    elif marks >= 50:
        print("Grade: C")
    else:
        print("Grade: F")

    3. Nested if Statements:

    age = 25
    if age >= 18:
        if age >= 21:
            print("Eligible for a full license.")
        else:
            print("Eligible for a provisional license.")
    else:
        print("Not eligible for a license.")
    

    4. Using Logical Operators:

    score = 85
    attendance = 90
    if score > 80 and attendance > 85:
        print("You passed with good standing!")

    5. Error Handling with Conditionals:

    try:
        age = int(input("Enter your age: "))
        if age >= 18:
            print("You are eligible to vote.")
        else:
            print("You are not eligible to vote.")
    except ValueError:
        print("Please enter a valid number.")

  • Learn Python Tamil Videos Step by Step Tutorials

    1. Introduction to Python Programming in Tamil | Python Course for Beginners
      Click to Watch Video
    2. Installation in Windows OS and Running Your First Program in IDLE
      Watch : Click to Watch Video
    3. Variables & Data Types Explained for Beginners
      Watch : Click to Watch Video
    4. Input and Output Explained for Beginners
      Watch : Click to Watch Video
    5. How to use Conditional Statements if ,elif, else
      Watch : Click to Watch Video
    6. How to use for and While Loop
      Watch : Click to Watch Video
    7. How to use List Creation, Access and Manipulation
      Watch : Click to Watch Video
    8. Python Dictionaries Explained | Key-Value Pair Basics
      Watch : Click to Watch Video
    9. Python Tuples Explained | Immutable Data Structure Basics
      Watch : Click to Watch Video
    10. Sets Data Structure in Tamil | Beginner-Friendly Guide
      Watch : Click to Watch Video
    11. Functions
      Watch : Click to Watch Video
    12. File Handling in Python: Read, Write, and Manage Files
      Watch : Click to Watch Video

  • Python – Functions Examples

    Example 1 :

    # Define a function
    def greet():
        print("Hello, World!")
    
    # Call the function
    greet()

    Output :

    Hello, World!

    Example 2 :

    # Define a function with parameters
    def greet(name):
        print(f"Hello, {name}!")
    
    # Call the function with an argument
    greet("Alice")

    Output :

    Hello, Alice!

    Example 3 :

    # Define a function with two parameters
    def add(a, b):
        return a + b
    
    # Call the function with arguments
    result = add(3, 4)
    print(result)

    Output :

    7

    Example 4 :

    # Define a function that returns a value
    def square(x):
        return x * x
    
    # Call the function and store the result
    result = square(5)
    print(result)

    Output :

    25

    Example 5 :

    # Define a function that returns multiple values
    def get_name_and_age():
        name = "Alice"
        age = 30
        return name, age
    
    # Call the function and unpack the result
    name, age = get_name_and_age()
    print(name, age)

    Output :

    Alice 30

    Example 6 : (Area of Circle using Functions)

    def areaofcircle(r):
        answer=3.14*r
        return answer
    
    radius=int(input("Enter Radius Value"))
    ans=areaofcircle(radius)
    print ("Answer",ans)

    Output :

    Enter Radius Value 1
    Answer 3.14

    Example 7 :

    def welcome(myname):
        msg="Hi " +myname + " Welcome to My Centre"
        return msg;
    
        
    m=input("Enter Your Name : ")
    print(welcome(m))
    

    Output :

    Enter Your Name : Raj
    Hi Raj Welcome to My Centre
  • Python – Syntax of If, For, While, Break, Continue

    1. If Statement

    if condition:
        # Code to execute if the condition is True
    
    if 5 > 3:
        print("5 is greater than 3")

    2. if-else Statement

    if condition:
        # Code to execute if the condition is True
    else:
        # Code to execute if the condition is False
    if 3 > 5:
        print("3 is greater than 5")
    else:
        print("3 is not greater than 5")

    3. if-elif-else Statement

    if condition1:
        # Code to execute if condition1 is True
    elif condition2:
        # Code to execute if condition2 is True
    else:
        # Code to execute if both conditions are False
    x = 10
    if x > 10:
        print("x is greater than 10")
    elif x == 10:
        print("x is equal to 10")
    else:
        print("x is less than 10")

    4.for Loop

    for variable in sequence:
        # Code to execute in each iteration
    for i in range(5):
        print(i)

    5.while Loop

    while condition:
    # Code to execute as long as the condition is True
    i = 0
    while i < 5:
        print(i)
        i += 1

    6.break Statement

    for/while variable in sequence/condition:
        if condition:
            break  # Exit the loop
    for i in range(10):
        if i == 5:
            break
        print(i)

    7. continue Statement

    for/while variable in sequence/condition:
        if condition:
            continue  # Skip the rest of the code in this iteration
        # Code to execute if the condition is not met
    for i in range(5):
        if i == 2:
            continue
        print(i)

    8. else with Loops

    for/while variable in sequence/condition:
        # Code to execute in each iteration
    else:
        # Code to execute after the loop finishes
    for i in range(3):
        print(i)
    else:
        print("Loop finished!")