π― Master Pythonπin 10 minutes π€―
Let us go on a journey to do cool things with Python π
Table of contents
- 1. Getting Started
- 2. Primitive Types
- 3. Control Flow
- 4. Functions
- 5. Data Structures
- β Lists
- β Accessing Items
- β List Unpacking
- β Looping over Lists
- β Adding/Removing items
- β Finding Items
- β Sorting Lists
- β Lambda Functions
- β Map Function
- β Filter Function
- β List Comprehensions
- β Zip Function
- β Stacks
- β Queues
- β Tuples
- β Swapping Variables
- β Arrays
- β Sets
- β Dictionaries
- β Dictionary Comprehensions
- β Generator Expressions
- β Unpacking Operator
- 6. Exceptions
- 7. Classes
- β Classes
- β Creating Classes
- β Constructors
- β Class vs Instance Attributes
- β Class vs Instance Methods
- β Magic Methods
- β Comparing Objects
- β Performing Arithmetic Operations
- β Making Custom Containers
- β Private Members
- β Properties
- β Inheritance
- β The Object Class
- β Method Overriding
- β Multi-level Inheritance
- β Multiple Inheritance
- β A Good Example of Inheritance
- β Abstract Base Classes
- β Polymorphism
- β Duck Typing
- β Extending Built-in Types
- β Data Classes
- 8. Modules
1. Getting Started
β What is Python ?
β Installing Python
- Download python from python.org
- Run the installer, check 'Add Python 3.10 to PATH', and install.
- Check the python version in the command prompt by using
python
command. - Download the latest version of VSCode editor from code.visualstudio.com
- Add Python extension from marketplace.
β Your First Python Program
- Create app.py and open it in VS Code.
- Run the file in the terminal using
python app.py
2. Primitive Types
β Variables
- Variables are used to store values in a computer's memory.
- Python is a case-sensitive language.
β Variable Names
- Variable names should be meaningful and descriptive.
- lowercase is used for naming
- Underscore(_) is used to separate multiple words
- space around =
β String
β Escape Sequences \" , \' , \, \n
β Formatted Strings
β String Methods
β Numbers
β Working with Numbers
β Type Conversion int(x), float(x), bool(x), str(x)
3. Control Flow
β Comparison Operators
β Conditional Statements
β Ternary Operator
β Logical Operators and,or,not
β Short-circuit Evaluation
β Chaining Comparison operators
β For Loops
β For..Else
β Nested Loops
β Iterables
β While loops
β Infinite Loops
4. Functions
β Defining Functions
β Arguments
β Types of Functions
β Keyword Arguments
β Default Arguments
β *args
β **args
β Scope
β Debugging (VERY IMPORTANT) : find and fix the bug
Run and debug -> Create launch.json file -> Python file
F9 -> insert a breakpoint
F5 -> run the application to this point
F10 -> execute one statement at a time
If we press F10 again execution stops
This time we want to step inside this multiply function so instead, press F11
Now we go inside the multiply function
Press F10 to go to the next line
Shift + F5 -> to stop the debugger
If we find the problem is a function set debug point inside that function
If we find everything is alright inside a function, use Shift + F11 -> to step out of that function
β VSCode Shotcut Windows
Home : beggining of line
End : end of line
Ctrl + Home/End : begin/end of file
Alt + Up/Down : move whole line up/down
Shift + Alt + up/down : copy line
Ctrl + / : comment
5. Data Structures
β Lists
β Accessing Items
β List Unpacking
β Looping over Lists
β Adding/Removing items
β Finding Items
β Sorting Lists
β Lambda Functions
β Map Function
β Filter Function
β List Comprehensions
β Zip Function
β Stacks
β Queues
β Tuples
β Swapping Variables
β Arrays
β Sets
β Dictionaries
β Dictionary Comprehensions
β Generator Expressions
β Unpacking Operator
6. Exceptions
β Exceptions
β Handling Exceptions
β Handling Different Exceptions
β Cleaning Up
β The With Statement
β Raising Exceptions
β Cost of Raising Exceptions
7. Classes
β Classes
β Creating Classes
β Constructors
β Class vs Instance Attributes
β Class vs Instance Methods
β Magic Methods
β Comparing Objects
β Performing Arithmetic Operations
β Making Custom Containers
β Private Members
β Properties
β Inheritance
β The Object Class
β Method Overriding
β Multi-level Inheritance
β Multiple Inheritance
β A Good Example of Inheritance
β Abstract Base Classes
β Polymorphism
β Duck Typing
β Extending Built-in Types
β Data Classes
8. Modules
β Creating Modules.mp4
β Compiled Python Files.mp4
β Module Search Path.mp4
β Packages.mp4
β Sub-packages.mp4
β Intra-package References.mp4
β The dir Function.mp4
β Executing Modules as Scripts
Β