Welcome to my Practice_Python GitHub repository!
This guide is designed to help you get started with Python, covering fundamental concepts such as basic arithmetic operations, loops, lists, conditional statements, functions, and connecting to MySQL databases.
TABLE OF CONTENTS
- Basic Arithmetic Operations
- Loops
- Lists
- Conditional Statements (if-else & ladder)
- Functions
- MySQL Connection
Basic Arithmetic Operations
Python supports all basic arithmetic operations such as addition (+), subtraction (-), multiplication (*), division (/), and exponentiation (**).
These operations can be performed on numerical data types like integers and floating-point numbers.
arithmetic operations in python
Loops
Loops in Python are used to repeatedly execute a block of code until a certain condition is met. There are two main types of loops: for loops and while loops. for loops iterate over a sequence (e.g., a list, tuple, or string), while while loops continue iterating as long as a specified condition is true.
loops in python
Lists
Lists are a fundamental data structure in Python used to store collections of items. Lists are ordered and mutable, meaning you can change the elements they contain. Elements in a list can be of different data types, and you can perform various operations on lists such as adding elements, removing elements, accessing elements by index, and iterating over the list using loops.
lists in python
Conditional Statements
Conditional statements like if, else, and elif (short for "else if") are used in Python to control the flow of the program based on certain conditions. The if statement allows you to execute a block of code only if a specified condition is true. The else statement is used to execute a block of code if the condition of the if statement is false. The elif statement allows you to check multiple conditions sequentially.
conditional statements in python
Functions
Functions in Python are reusable blocks of code that perform a specific task. They allow you to break down your code into smaller, manageable pieces, making it easier to read, understand, and maintain. Functions can take input parameters, perform operations on them, and optionally return a result. They help promote code reusability and modularity..
functions in python
MySQL Connection
Python provides various libraries for connecting to MySQL databases, such as mysql-connector-python. These libraries allow you to establish a connection to a MySQL database server, execute SQL queries, fetch results, and perform database operations programmatically from within your Python code. MySQL connections typically involve providing connection parameters like host, username, password, and database name.)
MySQL connection in python