Variables | x = 5 | Assigning a value to a variable |
Data Types | int, float, str, list, tuple, dict | Common data types in Python |
Lists | my_list = [1, 2, 3] | Creating a list |
Tuples | my_tuple = (1, 2, 3) | Creating a tuple |
Dictionaries | my_dict = {"key": "value"} | Creating a dictionary |
Functions | def my_function(): | Defining a function |
If Statements | if x > 0: | Basic if statement |
Loops | for i in range(5): | For loop |
While Loops | while x < 5: | While loop |
List Comprehension | [x for x in range(5)] | List comprehension |
Importing Modules | import math | Importing a module |
Classes | class MyClass: | Defining a class |
Inheritance | class ChildClass(ParentClass): | Defining a child class |
Exception Handling | try: ... except: ... | Handling exceptions |
File I/O | with open('file.txt', 'r') as file: | Reading from a file |
Lambda Function | lambda x: x + 1 | Anonymous function |