Course Content
What is Python?
Introduction of Python and Its setup
0/2
Control Statement
Control statements are used to control the flow of execution depending upon the specified condition/logic.
0/5
File Handling
File handling is an important component of any application. Python has multiple functions for creating, reading, updating, and deleting files.
0/2
Python
    About Lesson

    Python is known for its simplicity and readability, making it a great programming language for beginners. Here’s a detailed guide to Python syntax with examples.

     

    Key Characteristics of Python Syntax

    1. Whitespace and Indentation:

      • Python uses indentation (spaces or tabs) to define code blocks instead of braces {} or keywords like begin/end.
      • Proper indentation is mandatory, and incorrect indentation will result in errors.
    2. Case Sensitivity:

      • Python is case-sensitive. For example, variable and Variable are treated as distinct identifiers.
    3. Line Structure:

      • Each statement typically occupies a single line.
      • Use a backslash () to continue a statement across multiple lines.

     

    Basic Syntax Elements

    1. Comments

    • Use the # symbol to write comments in Python. Comments are ignored during execution and are used to explain code.

    2. Variables and Assignment

    • Variables store data. No explicit declaration is required.

    3. Data Types

    • Python supports several data types: int, float, str, bool, list, tuple, dict, and set.

     

    Indentation

    In Python, indentation is used to define blocks of code, such as functions, loops, and conditionals.

    • Indentation must be consistent. For example:
      • Either use 4 spaces or a single tab per level of indentation.

     

    if 6 > 3:
    print("Six is greater than three") # Indented block

     

    Basic Operations

    1. Arithmetic Operators

    • Perform basic arithmetic like addition, subtraction, multiplication, and division.

    2. Comparison Operators

    • Compare values (e.g., equal, greater than, less than).

    3. Logical Operators

    • Perform logical operations like and, or, and not.