Python Notes | 6th Sem | NEP2022
Python Notes | 6th Sem | NEP2022
3. Interpreter Shell
Python provides an interactive shell where you can type code line by line and see immediate results, useful for
testing and debugging.
4. Indentation
Python uses indentation (whitespace) to define blocks of code. It replaces the use of curly braces as in other
languages.
5. Comments
Single-line comments start with #. Multi-line comments use triple quotes (''' or ").
7. Literals
Literals are fixed values assigned to variables, such as numeric (int, float), string, boolean, and special literals like
None.
8. Basic Operators
Python includes Arithmetic (+, -, *, /), Relational (==, !=), Logical (and, or, not), Assignment (=, +=), and Bitwise (&,
|, ^) operators.
11. Variables
Variables are containers for storing data values. They are dynamically typed, meaning their type is inferred.
1. Functions
Functions are reusable blocks of code defined using the def keyword. They perform specific tasks and can be called
multiple times.
3. Return Values
Functions can return results to the caller using the return statement. If no return is used, the function returns
None.
5. Scope of Variables
Local scope means a variable is accessible only inside its function. Global scope means a variable is accessible
throughout the program. Use the global keyword to modify global variables inside functions.