├── Day01 ├── 01-shell-vs-python.md └── 02-hello-world.py ├── Day02 ├── Examples │ ├── 01-string-concat.py │ ├── 01-string-len.py │ ├── 01-string-lowercase.py │ ├── 01-string-replace.py │ ├── 01-string-split.py │ ├── 01-string-strip.py │ ├── 01-string-substring.py │ ├── 02-float.py │ ├── 02-int.py │ ├── 03-regex-findall.py │ ├── 03-regex-match.py │ ├── 03-regex-replace.py │ ├── 03-regex-search.py │ └── 03-regex-split.py └── Theory │ ├── 01-data-types.md │ ├── 02-strings.md │ ├── 03-numeric.md │ └── 04-regex.md ├── Day03 ├── keywords.md └── variables.md ├── Day04 ├── README.md ├── def_key.py ├── exp1.py ├── my_module.py └── try_module.py ├── Day05 ├── command-line-arguments.py └── enev-var.py ├── Day06 ├── assgn │ ├── arthematic-opr.py │ ├── assginment-opr.py │ ├── comparision-opr.py │ ├── exp.py │ ├── logical-opr.py │ └── questions.md └── notes │ ├── Arithmetic │ ├── Assignment │ ├── Bitwise │ ├── Identity │ ├── Logical │ ├── Membership │ ├── Precedence │ └── Relational ├── Day07 ├── README.md ├── conditions.py └── somcond.py ├── Day08 ├── assgn │ ├── 01-lists.py │ ├── 02-tupels.py │ ├── 03-lists_append_remove.py │ ├── 04-00-list-questions.md │ ├── 04-01-list-answers.md │ ├── sort_mechanism.py │ ├── tounge-catination.py │ └── tounge-catination1.py └── notes │ ├── 01-list.md │ ├── 02-tuple.md │ ├── 03-list-vs-tuple.md │ └── 04-faq.md ├── Day09 ├── assgn │ ├── loop-00-exp.py │ ├── loop-01-exp.py │ ├── loop-02-exp.py │ ├── loop-03-exp.py │ ├── loop-04-exp.py │ ├── loop-05-exp.py │ ├── loop-break.py │ ├── loop-continue.py │ └── while.py └── notes │ ├── 01-loops.md │ ├── 02-loop-controls.md │ ├── 03-for-loop-devops-usecases.md │ └── 04-while-loop-devops-usecases.md └── README.md /Day01/01-shell-vs-python.md: -------------------------------------------------------------------------------- 1 | Certainly! The choice between using shell scripting and Python in DevOps depends on the specific task or problem you're trying to solve. Both have their strengths and are suitable for different scenarios. Here are some guidelines to help you decide when to use each: 2 | 3 | **Use Shell Scripting When:** 4 | 5 | 1. **System Administration Tasks:** Shell scripting is excellent for automating routine system administration tasks like managing files, directories, and processes. You can use shell scripts for tasks like starting/stopping services, managing users, and basic file manipulation. 6 | 7 | 2. **Command Line Interactions:** If your task primarily involves running command line tools and utilities, shell scripting can be more efficient. It's easy to call and control these utilities from a shell script. 8 | 9 | 3. **Rapid Prototyping:** If you need to quickly prototype a solution or perform one-off tasks, shell scripting is usually faster to write and execute. It's great for ad-hoc tasks. 10 | 11 | 4. **Text Processing:** Shell scripting is well-suited for tasks that involve text manipulation, such as parsing log files, searching and replacing text, or extracting data from text-based sources. 12 | 13 | 5. **Environment Variables and Configuration:** Shell scripts are useful for managing environment variables and configuring your system. 14 | 15 | **Use Python When:** 16 | 17 | 1. **Complex Logic:** Python is a full-fledged programming language and is well-suited for tasks that involve complex logic, data structures, and algorithms. If your task requires extensive data manipulation, Python can be a more powerful choice. 18 | 19 | 2. **Cross-Platform Compatibility:** Python is more platform-independent than shell scripting, making it a better choice for tasks that need to run on different operating systems. 20 | 21 | 3. **API Integration:** Python has extensive libraries and modules for interacting with APIs, databases, and web services. If your task involves working with APIs, Python may be a better choice. 22 | 23 | 4. **Reusable Code:** If you plan to reuse your code or build larger applications, Python's structure and modularity make it easier to manage and maintain. 24 | 25 | 5. **Error Handling:** Python provides better error handling and debugging capabilities, which can be valuable in DevOps where reliability is crucial. 26 | 27 | 6. **Advanced Data Processing:** If your task involves advanced data processing, data analysis, or machine learning, Python's rich ecosystem of libraries (e.g., Pandas, NumPy, SciPy) makes it a more suitable choice. 28 | -------------------------------------------------------------------------------- /Day01/02-hello-world.py: -------------------------------------------------------------------------------- 1 | print("Hello, World!") 2 | 3 | -------------------------------------------------------------------------------- /Day02/Examples/01-string-concat.py: -------------------------------------------------------------------------------- 1 | str1 = "Hello" 2 | str2 = "World" 3 | result = str1 + " " + str2 4 | print(result) 5 | -------------------------------------------------------------------------------- /Day02/Examples/01-string-len.py: -------------------------------------------------------------------------------- 1 | text = "Python is awesome just staring the basics classes 05-11-2023" 2 | length = len(text) 3 | print("Length of the string:", length) 4 | -------------------------------------------------------------------------------- /Day02/Examples/01-string-lowercase.py: -------------------------------------------------------------------------------- 1 | text = "Python is awesome Lower to Upper Cases Checking VIKASH M" 2 | uppercase = text.upper() 3 | lowercase = text.lower() 4 | print("Uppercase:", uppercase) 5 | print("Lowercase:", lowercase) 6 | -------------------------------------------------------------------------------- /Day02/Examples/01-string-replace.py: -------------------------------------------------------------------------------- 1 | text = "Python is awesome" 2 | new_text = text.replace("awesome", "Starting") 3 | print("Modified text:", new_text) 4 | -------------------------------------------------------------------------------- /Day02/Examples/01-string-split.py: -------------------------------------------------------------------------------- 1 | text = "Python is awesome" 2 | words = text.split() 3 | print("Words:", words) 4 | -------------------------------------------------------------------------------- /Day02/Examples/01-string-strip.py: -------------------------------------------------------------------------------- 1 | text = " Some spaces around " 2 | stripped_text = text.strip() 3 | print("Stripped text:", stripped_text) 4 | -------------------------------------------------------------------------------- /Day02/Examples/01-string-substring.py: -------------------------------------------------------------------------------- 1 | text = "Python is awesome" 2 | substring = "is" 3 | if substring in text: 4 | print(substring, "found in the text") 5 | -------------------------------------------------------------------------------- /Day02/Examples/02-float.py: -------------------------------------------------------------------------------- 1 | # Float variables 2 | num1 = 5.0 3 | num2 = 2.5 4 | 5 | # Basic Arithmetic 6 | result1 = num1 + num2 7 | print("Addition:", result1) 8 | 9 | result2 = num1 - num2 10 | print("Subtraction:", result2) 11 | 12 | result3 = num1 * num2 13 | print("Multiplication:", result3) 14 | 15 | result4 = num1 / num2 16 | print("Division:", result4) 17 | 18 | # Rounding 19 | result5 = round(3.14159265359, 2) # Rounds to 2 decimal places 20 | print("Rounded:", result5) 21 | -------------------------------------------------------------------------------- /Day02/Examples/02-int.py: -------------------------------------------------------------------------------- 1 | # Integer variables 2 | num1 = 10 3 | num2 = 5 4 | 5 | # Integer Division 6 | result1 = num1 // num2 7 | print("Integer Division:", result1) 8 | 9 | # Modulus (Remainder) 10 | result2 = num1 % num2 11 | print("Modulus (Remainder):", result2) 12 | 13 | # Absolute Value 14 | result3 = abs(-7) 15 | print("Absolute Value:", result3) 16 | -------------------------------------------------------------------------------- /Day02/Examples/03-regex-findall.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | text = "The quick brown fox" 4 | pattern = r"brown" 5 | 6 | search = re.search(pattern, text) 7 | if search: 8 | print("Pattern found:", search.group()) 9 | else: 10 | print("Pattern not found") 11 | -------------------------------------------------------------------------------- /Day02/Examples/03-regex-match.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | text = "The quick brown fox" 4 | pattern = r"quick" 5 | 6 | match = re.match(pattern, text) 7 | if match: 8 | print("Match found:", match.group()) 9 | else: 10 | print("No match") 11 | -------------------------------------------------------------------------------- /Day02/Examples/03-regex-replace.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | text = "The quick brown fox jumps over the lazy brown dog" 4 | pattern = r"brown" 5 | 6 | replacement = "red" 7 | 8 | new_text = re.sub(pattern, replacement, text) 9 | print("Modified text:", new_text) 10 | -------------------------------------------------------------------------------- /Day02/Examples/03-regex-search.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | text = "The quick brown fox" 4 | pattern = r"brown" 5 | 6 | search = re.search(pattern, text) 7 | if search: 8 | print("Pattern found:", search.group()) 9 | else: 10 | print("Pattern not found") 11 | -------------------------------------------------------------------------------- /Day02/Examples/03-regex-split.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | text = "apple,banana,orange,grape" 4 | pattern = r"," 5 | 6 | split_result = re.split(pattern, text) 7 | print("Split result:", split_result) 8 | -------------------------------------------------------------------------------- /Day02/Theory/01-data-types.md: -------------------------------------------------------------------------------- 1 | # Data Types 2 | 3 | In programming, a data type is a classification or categorization that specifies which type of value a variable can hold. Data types are essential because they determine how data is stored in memory and what operations can be performed on that data. Python, like many programming languages, supports several built-in data types. Here are some of the common data types in Python: 4 | 5 | 1. **Numeric Data Types:** 6 | - **int**: Represents integers (whole numbers). Example: `x = 5` 7 | - **float**: Represents floating-point numbers (numbers with decimal points). Example: `y = 3.14` 8 | - **complex**: Represents complex numbers. Example: `z = 2 + 3j` 9 | 10 | 2. **Sequence Types:** 11 | - **str**: Represents strings (sequences of characters). Example: `text = "Hello, World"` 12 | - **list**: Represents lists (ordered, mutable sequences). Example: `my_list = [1, 2, 3]` 13 | - **tuple**: Represents tuples (ordered, immutable sequences). Example: `my_tuple = (1, 2, 3)` 14 | 15 | 3. **Mapping Type:** 16 | - **dict**: Represents dictionaries (key-value pairs). Example: `my_dict = {'name': 'John', 'age': 30}` 17 | 18 | 4. **Set Types:** 19 | - **set**: Represents sets (unordered collections of unique elements). Example: `my_set = {1, 2, 3}` 20 | - **frozenset**: Represents immutable sets. Example: `my_frozenset = frozenset([1, 2, 3])` 21 | 22 | 5. **Boolean Type:** 23 | - **bool**: Represents Boolean values (`True` or `False`). Example: `is_valid = True` 24 | 25 | 6. **Binary Types:** 26 | - **bytes**: Represents immutable sequences of bytes. Example: `data = b'Hello'` 27 | - **bytearray**: Represents mutable sequences of bytes. Example: `data = bytearray(b'Hello')` 28 | 29 | 7. **None Type:** 30 | - **NoneType**: Represents the `None` object, which is used to indicate the absence of a value or a null value. 31 | 32 | 8. **Custom Data Types:** 33 | - You can also define your custom data types using classes and objects. 34 | -------------------------------------------------------------------------------- /Day02/Theory/02-strings.md: -------------------------------------------------------------------------------- 1 | # Strings 2 | 3 | **1. String Data Type in Python:** 4 | 5 | - In Python, a string is a sequence of characters, enclosed within single (' '), double (" "), or triple (''' ''' or """ """) quotes. 6 | - Strings are immutable, meaning you cannot change the characters within a string directly. Instead, you create new strings. 7 | - You can access individual characters in a string using indexing, e.g., `my_string[0]` will give you the first character. 8 | - Strings support various built-in methods, such as `len()`, `upper()`, `lower()`, `strip()`, `replace()`, and more, for manipulation. 9 | 10 | **2. String Manipulation and Formatting:** 11 | 12 | - Concatenation: You can combine strings using the `+` operator. 13 | - Substrings: Use slicing to extract portions of a string, e.g., `my_string[2:5]` will extract characters from the 2nd to the 4th position. 14 | - String interpolation: Python supports various ways to format strings, including f-strings (f"...{variable}..."), %-formatting ("%s %d" % ("string", 42)), and `str.format()`. 15 | - Escape sequences: Special characters like newline (\n), tab (\t), and others are represented using escape sequences. 16 | - String methods: Python provides many built-in methods for string manipulation, such as `split()`, `join()`, and `startswith()`. 17 | -------------------------------------------------------------------------------- /Day02/Theory/03-numeric.md: -------------------------------------------------------------------------------- 1 | # Numberic Data Type 2 | 3 | **1. Numeric Data Types in Python (int, float):** 4 | 5 | - Python supports two primary numeric data types: `int` for integers and `float` for floating-point numbers. 6 | - Integers are whole numbers, and floats can represent both whole and fractional numbers. 7 | - You can perform arithmetic operations on these types, including addition, subtraction, multiplication, division, and more. 8 | - Be aware of potential issues with floating-point precision, which can lead to small inaccuracies in calculations. 9 | - Python also provides built-in functions for mathematical operations, such as `abs()`, `round()`, and `math` module for advanced functions. 10 | -------------------------------------------------------------------------------- /Day02/Theory/04-regex.md: -------------------------------------------------------------------------------- 1 | # Regex 2 | 3 | **1. Regular Expressions for Text Processing:** 4 | 5 | - Regular expressions (regex or regexp) are a powerful tool for pattern matching and text processing. 6 | - The `re` module in Python is used for working with regular expressions. 7 | - Common metacharacters: `.` (any character), `*` (zero or more), `+` (one or more), `?` (zero or one), `[]` (character class), `|` (OR), `^` (start of a line), `$` (end of a line), etc. 8 | - Examples of regex usage: matching emails, phone numbers, or extracting data from text. 9 | - `re` module functions include `re.match()`, `re.search()`, `re.findall()`, and `re.sub()` for pattern matching and replacement. 10 | -------------------------------------------------------------------------------- /Day03/keywords.md: -------------------------------------------------------------------------------- 1 | # Keywords in Python: 2 | 3 | Keywords are reserved words in Python that have predefined meanings and cannot be used as variable names or identifiers. These words are used to define the structure and logic of the program. They are an integral part of the Python language and are case-sensitive, which means you must use them exactly as specified. 4 | 5 | Here are some important Python keywords: 6 | 7 | 1. **and**: It is a logical operator that returns `True` if both operands are true. 8 | 9 | 2. **or**: It is a logical operator that returns `True` if at least one of the operands is true. 10 | 11 | 3. **not**: It is a logical operator that returns the opposite of the operand's truth value. 12 | 13 | 4. **if**: It is used to start a conditional statement and is followed by a condition that determines whether the code block is executed. 14 | 15 | 5. **else**: It is used in conjunction with `if` to define an alternative code block to execute when the `if` condition is `False`. 16 | 17 | 6. **elif**: Short for "else if," it is used to check additional conditions after an `if` statement and is used in combination with `if` and `else`. 18 | 19 | 7. **while**: It is used to create a loop that repeatedly executes a block of code as long as a specified condition is true. 20 | 21 | 8. **for**: It is used to create a loop that iterates over a sequence (such as a list, tuple, or string) and executes a block of code for each item in the sequence. 22 | 23 | 9. **in**: Used with `for`, it checks if a value is present in a sequence. 24 | 25 | 10. **try**: It is the beginning of a block of code that is subject to exception handling. It is followed by `except` to catch and handle exceptions. 26 | 27 | 11. **except**: Used with `try`, it defines a block of code to execute when an exception is raised in the corresponding `try` block. 28 | 29 | 12. **finally**: Used with `try`, it defines a block of code that is always executed, whether an exception is raised or not. 30 | 31 | 13. **def**: It is used to define a function in Python. 32 | 33 | 14. **return**: It is used within a function to specify the value that the function should return. 34 | 35 | 15. **class**: It is used to define a class, which is a blueprint for creating objects in object-oriented programming. 36 | 37 | 16. **import**: It is used to import modules or libraries to access their functions, classes, or variables. 38 | 39 | 17. **from**: Used with `import` to specify which specific components from a module should be imported. 40 | 41 | 18. **as**: Used with `import` to create an alias for a module, making it easier to reference in the code. 42 | 43 | 19. **True**: It represents a boolean value for "true." 44 | 45 | 20. **False**: It represents a boolean value for "false." 46 | 47 | 21. **None**: It represents a special null value or absence of value. 48 | 49 | 22. **is**: It is used for identity comparison, checking if two variables refer to the same object in memory. 50 | 51 | 23. **lambda**: It is used to create small, anonymous functions (lambda functions). 52 | 53 | 24. **with**: It is used for context management, ensuring that certain operations are performed before and after a block of code. 54 | 55 | 25. **global**: It is used to declare a global variable within a function's scope. 56 | 57 | 26. **nonlocal**: It is used to declare a variable as nonlocal, which allows modifying a variable in an enclosing (but non-global) scope. 58 | -------------------------------------------------------------------------------- /Day03/variables.md: -------------------------------------------------------------------------------- 1 | # Understanding Variables in Python: 2 | 3 | In Python, a variable is a named storage location used to store data. Variables are essential for programming as they allow us to work with data, manipulate it, and make our code more flexible and reusable. 4 | 5 | #### Example: 6 | 7 | ```python 8 | # Assigning a value to a variable 9 | my_variable = 42 10 | 11 | # Accessing the value of a variable 12 | print(my_variable) # Output: 42 13 | ``` 14 | 15 | ### Variable Scope and Lifetime: 16 | 17 | **Variable Scope:** In Python, variables have different scopes, which determine where in the code the variable can be accessed. There are mainly two types of variable scopes: 18 | 19 | 1. **Local Scope:** Variables defined within a function have local scope and are only accessible inside that function. 20 | 21 | ```python 22 | def my_function(): 23 | x = 10 # Local variable 24 | print(x) 25 | 26 | my_function() 27 | print(x) # This will raise an error since 'x' is not defined outside the function. 28 | ``` 29 | 30 | 2. **Global Scope:** Variables defined outside of any function have global scope and can be accessed throughout the entire code. 31 | 32 | ```python 33 | y = 20 # Global variable 34 | 35 | def another_function(): 36 | print(y) # This will access the global variable 'y' 37 | 38 | another_function() 39 | print(y) # This will print 20 40 | ``` 41 | 42 | **Variable Lifetime:** The lifetime of a variable is determined by when it is created and when it is destroyed or goes out of scope. Local variables exist only while the function is being executed, while global variables exist for the entire duration of the program. 43 | 44 | ### Variable Naming Conventions and Best Practices: 45 | 46 | It's important to follow naming conventions and best practices for variables to write clean and maintainable code: 47 | 48 | - Variable names should be descriptive and indicate their purpose. 49 | - Use lowercase letters and separate words with underscores (snake_case) for variable names. 50 | - Avoid using reserved words (keywords) for variable names. 51 | - Choose meaningful names for variables. 52 | 53 | #### Example: 54 | 55 | ```python 56 | # Good variable naming 57 | user_name = "John" 58 | total_items = 42 59 | 60 | # Avoid using reserved words 61 | class = "Python" # Not recommended 62 | 63 | # Use meaningful names 64 | a = 10 # Less clear 65 | num_of_students = 10 # More descriptive 66 | ``` 67 | 68 | ### Practice Exercises and Examples: 69 | 70 | #### Example: Using Variables to Store and Manipulate Configuration Data in a DevOps Context 71 | 72 | In a DevOps context, you often need to manage configuration data for various services or environments. Variables are essential for this purpose. Let's consider a scenario where we need to store and manipulate configuration data for a web server. 73 | 74 | ```python 75 | # Define configuration variables for a web server 76 | server_name = "my_server" 77 | port = 80 78 | is_https_enabled = True 79 | max_connections = 1000 80 | 81 | # Print the configuration 82 | print(f"Server Name: {server_name}") 83 | print(f"Port: {port}") 84 | print(f"HTTPS Enabled: {is_https_enabled}") 85 | print(f"Max Connections: {max_connections}") 86 | 87 | # Update configuration values 88 | port = 443 89 | is_https_enabled = False 90 | 91 | # Print the updated configuration 92 | print(f"Updated Port: {port}") 93 | print(f"Updated HTTPS Enabled: {is_https_enabled}") 94 | ``` 95 | 96 | In this example, we use variables to store and manipulate configuration data for a web server. This allows us to easily update and manage the server's configuration in a DevOps context. 97 | -------------------------------------------------------------------------------- /Day04/README.md: -------------------------------------------------------------------------------- 1 | # Python Functions, Modules and Packages 2 | 3 | ## 1. Differences Between Functions, Modules, and Packages 4 | 5 | ### Functions 6 | 7 | A function in Python is a block of code that performs a specific task. Functions are defined using the `def` keyword and can take inputs, called arguments. They are a way to encapsulate and reuse code. 8 | 9 | **Example:** 10 | 11 | ```python 12 | def greet(name): 13 | return f"Hello, {name}!" 14 | 15 | message = greet("Alice") 16 | print(message) 17 | ``` 18 | 19 | In this example, `greet` is a function that takes a `name` argument and returns a greeting message. 20 | 21 | ### Modules 22 | 23 | A module is a Python script containing Python code. It can define functions, classes, and variables that can be used in other Python scripts. Modules help organize and modularize your code, making it more maintainable. 24 | 25 | **Example:** 26 | 27 | Suppose you have a Python file named `my_module.py`: 28 | 29 | ```python 30 | # my_module.py 31 | def square(x): 32 | return x ** 2 33 | 34 | pi = 3.14159265 35 | ``` 36 | 37 | You can use this module in another script: 38 | 39 | ```python 40 | import my_module 41 | 42 | result = my_module.square(5) 43 | print(result) 44 | print(my_module.pi) 45 | ``` 46 | 47 | In this case, `my_module` is a Python module containing the `square` function and a variable `pi`. 48 | 49 | ### Packages 50 | 51 | A package is a collection of modules organized in directories. Packages help you organize related modules into a hierarchy. They contain a special file named `__init__.py`, which indicates that the directory should be treated as a package. 52 | 53 | **Example:** 54 | 55 | Suppose you have a package structure as follows: 56 | 57 | ``` 58 | my_package/ 59 | __init__.py 60 | module1.py 61 | module2.py 62 | ``` 63 | 64 | You can use modules from this package as follows: 65 | 66 | ```python 67 | from my_package import module1 68 | 69 | result = module1.function_from_module1() 70 | ``` 71 | 72 | In this example, `my_package` is a Python package containing modules `module1` and `module2`. 73 | 74 | ## 2. How to Import a Package 75 | 76 | Importing a package or module in Python is done using the `import` statement. You can import the entire package, specific modules, or individual functions/variables from a module. 77 | 78 | **Example:** 79 | 80 | ```python 81 | # Import the entire module 82 | import math 83 | 84 | # Use functions/variables from the module 85 | result = math.sqrt(16) 86 | print(result) 87 | 88 | # Import specific function/variable from a module 89 | from math import pi 90 | print(pi) 91 | ``` 92 | 93 | In this example, we import the `math` module and then use functions and variables from it. You can also import specific elements from modules using the `from module import element` syntax. 94 | 95 | ## 3. Python Workspaces 96 | 97 | Python workspaces refer to the environment in which you develop and run your Python code. They include the Python interpreter, installed libraries, and the current working directory. Understanding workspaces is essential for managing dependencies and code organization. 98 | 99 | Python workspaces can be local or virtual environments. A local environment is the system-wide Python installation, while a virtual environment is an isolated environment for a specific project. You can create virtual environments using tools like `virtualenv` or `venv`. 100 | 101 | **Example:** 102 | 103 | ```bash 104 | # Create a virtual environment 105 | python -m venv myenv 106 | $ python -m ven project-abc 107 | 108 | 109 | 110 | # Activate the virtual environment (on Windows) 111 | myenv\Scripts\activate 112 | $ project-abc\scripts\activate 113 | 114 | 115 | # Activate the virtual environment (on macOS/Linux) 116 | source myenv/bin/activate 117 | $ project-abc/bin/activate 118 | 119 | # Deactivate the particular virtual environmet 120 | $ deactivate //when we are inside that environment 121 | ``` 122 | 123 | Once activated, you work in an isolated workspace with its Python interpreter and library dependencies. 124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /Day04/def_key.py: -------------------------------------------------------------------------------- 1 | num1 = 17 2 | num2 = 2 3 | 4 | def addition(): 5 | add = num1 + num2 6 | print(add) 7 | 8 | def sub(): 9 | s = num1 -num2 10 | print(s) 11 | 12 | def mul(): 13 | m = num1 * num2 14 | print(m) 15 | 16 | def division(): 17 | div = num1 / num2 18 | print(div) 19 | 20 | 21 | addition() 22 | sub() 23 | mul() 24 | division() 25 | 26 | -------------------------------------------------------------------------------- /Day04/exp1.py: -------------------------------------------------------------------------------- 1 | # In this example, def is Keyword, greet is a function that takes a name argument and returns a greeting message. 2 | 3 | def greet(name): 4 | return f"Hello, {name}!" 5 | 6 | message = greet("Alice") 7 | print(message) 8 | 9 | 10 | 11 | def greet(name): 12 | return f"HELLO, {name}!!!!" 13 | 14 | checking = greet("Akhi") 15 | print(checking) 16 | -------------------------------------------------------------------------------- /Day04/my_module.py: -------------------------------------------------------------------------------- 1 | # my_module.py 2 | def square(x): 3 | return x ** 2 4 | 5 | pi = 3.14159265 6 | -------------------------------------------------------------------------------- /Day04/try_module.py: -------------------------------------------------------------------------------- 1 | import my_module 2 | 3 | result = my_module.square(5) 4 | print(result) 5 | print(my_module.pi) 6 | -------------------------------------------------------------------------------- /Day05/command-line-arguments.py: -------------------------------------------------------------------------------- 1 | import sys # Here sys is the module, it will installed inbuilt, just we are calling the argument. 2 | 3 | def add(num1, num2): # Here 1)Keywords = def. --> 2)functions = add, sub, mul, division --> 3)Datatypes = float. 4 | add = num1 + num2 5 | return add # Return is the statement to return the result of the given programm. 6 | 7 | 8 | def sub(num1, num2): 9 | s = num1 - num2 10 | return s 11 | 12 | def mul(num1, num2): 13 | m = num1 * num2 14 | return m 15 | 16 | def division(num1, num2): 17 | div = num1 / num2 18 | return div 19 | 20 | num1 = float(sys.argv[1]) 21 | operation = sys.argv[2] 22 | num2 = float(sys.argv[3]) 23 | 24 | if operation == "add": # Desired operations = operations. 25 | output = add(num1, num2) 26 | print(output) 27 | 28 | 29 | if operation == "sub": 30 | output = sub(num1, num2) 31 | print(output) 32 | 33 | 34 | if operation == "mul": 35 | output = mul(num1, num2) 36 | print(output) 37 | 38 | 39 | if operation == "division": 40 | output = division(num1, num2) 41 | print(output) 42 | 43 | -------------------------------------------------------------------------------- /Day05/enev-var.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | print(os.getenv("password")) 5 | 6 | print(os.getenv("apitoken")) 7 | 8 | # Here we are passing environment variables like $ export password="vikash" it execute it. 9 | 10 | # $ export apitoken="adfas21$%adfag231#vikash" 11 | -------------------------------------------------------------------------------- /Day06/assgn/arthematic-opr.py: -------------------------------------------------------------------------------- 1 | a=2 2 | b=3 3 | 4 | def addition(): 5 | add = a + b 6 | print(add) 7 | 8 | 9 | addition() 10 | -------------------------------------------------------------------------------- /Day06/assgn/assginment-opr.py: -------------------------------------------------------------------------------- 1 | total = 10 2 | 3 | total += 5 4 | total -= 3 5 | total *= 2 6 | total /= 4 7 | 8 | print("Final total:", total) 9 | -------------------------------------------------------------------------------- /Day06/assgn/comparision-opr.py: -------------------------------------------------------------------------------- 1 | a1=6 2 | b1=6 3 | 4 | def equal(): 5 | equal = a1 == b1 6 | print("a1 == b1:", equal) 7 | 8 | equal() 9 | 10 | 11 | 12 | a = 10 13 | b = 5 14 | 15 | less_than = a < b 16 | greater_than = a > b 17 | less_than_or_equal = a <= b 18 | greater_than_or_equal = a >= b 19 | equal = a == b 20 | not_equal = a != b 21 | 22 | print("a < b:", less_than) 23 | print("a > b:", greater_than) 24 | print("a <= b:", less_than_or_equal) 25 | print("a >= b:", greater_than_or_equal) 26 | print("a == b:", equal) 27 | print("a != b:", not_equal) 28 | -------------------------------------------------------------------------------- /Day06/assgn/exp.py: -------------------------------------------------------------------------------- 1 | my_list = [1, 2, 3, 4, 5] 2 | 3 | # Identity operators 4 | a = my_list 5 | b = [1, 2, 3, 4, 5] 6 | 7 | is_same_object = a is my_list 8 | is_not_same_object = b is not my_list 9 | 10 | # Membership operators 11 | element_in_list = 3 in my_list 12 | element_not_in_list = 6 not in my_list 13 | 14 | print("a is my_list:", is_same_object) 15 | print("b is not my_list:", is_not_same_object) 16 | print("3 in my_list:", element_in_list) 17 | print("6 not in my_list:", element_not_in_list) 18 | -------------------------------------------------------------------------------- /Day06/assgn/logical-opr.py: -------------------------------------------------------------------------------- 1 | x = True 2 | y = False 3 | 4 | and_result = x and y 5 | or_result = x or y 6 | not_result_x = not x 7 | not_result_y = not y 8 | 9 | print("x and y:", and_result) 10 | print("x or y:", or_result) 11 | print("not x:", not_result_x) 12 | print("not y:", not_result_y) 13 | -------------------------------------------------------------------------------- /Day06/assgn/questions.md: -------------------------------------------------------------------------------- 1 | 2 | # Python Operators Assignment 3 | 4 | In this assignment, you will explore various Python operators and their usage. Please complete the following tasks. 5 | 6 | ## Task 1: Arithmetic Operators 7 | 8 | 1. Create two variables `a` and `b` with numeric values. 9 | 2. Calculate the sum, difference, product, and quotient of `a` and `b`. 10 | 3. Print the results. 11 | 12 | ## Task 2: Comparison Operators 13 | 14 | 1. Compare the values of `a` and `b` using the following comparison operators: `<`, `>`, `<=`, `>=`, `==`, and `!=`. 15 | 2. Print the results of each comparison. 16 | 17 | ## Task 3: Logical Operators 18 | 19 | 1. Create two boolean variables, `x` and `y`. 20 | 2. Use logical operators (`and`, `or`, `not`) to perform various logical operations on `x` and `y`. 21 | 3. Print the results. 22 | 23 | ## Task 4: Assignment Operators 24 | 25 | 1. Create a variable `total` and initialize it to 10. 26 | 2. Use assignment operators (`+=`, `-=`, `*=`, `/=`) to update the value of `total`. 27 | 3. Print the final value of `total`. 28 | 29 | ## Task 5: Bitwise Operators (Optional) 30 | 31 | 1. If you are comfortable with bitwise operators, perform some bitwise operations on integer values and print the results. If not, you can skip this task. 32 | 33 | ## Task 6: Identity and Membership Operators 34 | 35 | 1. Create a list `my_list` containing a few elements. 36 | 2. Use identity operators (`is` and `is not`) to check if two variables are the same object. 37 | 3. Use membership operators (`in` and `not in`) to check if an element is present in `my_list`. 38 | 4. Print the results. 39 | 40 | 41 | -------------------------------------------------------------------------------- /Day06/notes/Arithmetic: -------------------------------------------------------------------------------- 1 | # Arithmetic Operations in Python 2 | 3 | ## Introduction 4 | 5 | Arithmetic operators in Python allow you to perform basic mathematical calculations on numeric values. These operators include addition, subtraction, multiplication, division, and more. 6 | 7 | ## List of Arithmetic Operators 8 | 9 | 1. **Addition (+):** Adds two numbers. 10 | 2. **Subtraction (-):** Subtracts the right operand from the left operand. 11 | 3. **Multiplication (*):** Multiplies two numbers. 12 | 4. **Division (/):** Divides the left operand by the right operand (results in a floating-point number). 13 | 5. **Floor Division (//):** Divides the left operand by the right operand and rounds down to the nearest whole number. 14 | 6. **Modulus (%):** Returns the remainder of the division of the left operand by the right operand. 15 | 7. **Exponentiation (**):** Raises the left operand to the power of the right operand. 16 | 17 | ## Examples 18 | 19 | ### Addition 20 | 21 | ```python 22 | a = 5 23 | b = 3 24 | result = a + b 25 | print(result) # Output: 8 26 | ``` 27 | 28 | ### Subtraction 29 | 30 | ```python 31 | x = 10 32 | y = 7 33 | result = x - y 34 | print(result) # Output: 3 35 | ``` 36 | -------------------------------------------------------------------------------- /Day06/notes/Assignment: -------------------------------------------------------------------------------- 1 | # Assignment Operations in Python 2 | 3 | ## Introduction 4 | 5 | Assignment operators in Python are used to assign values to variables. They include the basic assignment operator (=) and various compound assignment operators that perform an operation on the variable while assigning a value. 6 | 7 | ## List of Assignment Operators 8 | 9 | 1. **Basic Assignment (=):** Assigns a value to a variable. 10 | 11 | 2. **Addition Assignment (+=):** Adds the right operand to the left operand and assigns the result to the left operand. 12 | 13 | 3. **Subtraction Assignment (-=):** Subtracts the right operand from the left operand and assigns the result to the left operand. 14 | 15 | 4. **Multiplication Assignment (*=):** Multiplies the left operand by the right operand and assigns the result to the left operand. 16 | 17 | 5. **Division Assignment (/=):** Divides the left operand by the right operand and assigns the result to the left operand. 18 | 19 | 6. **Floor Division Assignment (//=):** Performs floor division on the left operand and assigns the result to the left operand. 20 | 21 | 7. **Modulus Assignment (%=):** Calculates the modulus of the left operand and assigns the result to the left operand. 22 | 23 | 8. **Exponentiation Assignment (**=):** Raises the left operand to the power of the right operand and assigns the result to the left operand. 24 | 25 | ## Examples 26 | 27 | ### Basic Assignment 28 | 29 | ```python 30 | x = 5 31 | ``` 32 | 33 | ### Addition Assignment 34 | 35 | ```python 36 | y = 10 37 | y += 3 # Equivalent to y = y + 3 38 | ``` 39 | -------------------------------------------------------------------------------- /Day06/notes/Bitwise: -------------------------------------------------------------------------------- 1 | # Bitwise Operations in Python 2 | 3 | ## Introduction 4 | 5 | Bitwise operators in Python are used to perform operations on individual bits of binary numbers. These operators include bitwise AND, OR, XOR, and more. 6 | 7 | ## List of Bitwise Operators 8 | 9 | 1. **Bitwise AND (&):** Performs a bitwise AND operation on the binary representations of the operands. 10 | 2. **Bitwise OR (|):** Performs a bitwise OR operation. 11 | 3. **Bitwise XOR (^):** Performs a bitwise XOR operation. 12 | 4. **Bitwise NOT (~):** Flips the bits of the operand, changing 0 to 1 and 1 to 0. 13 | 5. **Left Shift (<<):** Shifts the bits to the left by a specified number of positions. 14 | 6. **Right Shift (>>):** Shifts the bits to the right. 15 | 16 | ## Examples 17 | 18 | ### Bitwise AND 19 | 20 | ```python 21 | a = 5 # Binary: 0101 22 | b = 3 # Binary: 0011 23 | result = a & b # Result: 0001 (Decimal: 1) 24 | ``` 25 | 26 | ### Bitwise OR 27 | 28 | ```python 29 | x = 10 # Binary: 1010 30 | y = 7 # Binary: 0111 31 | result = x | y # Result: 1111 (Decimal: 15) 32 | ``` 33 | -------------------------------------------------------------------------------- /Day06/notes/Identity: -------------------------------------------------------------------------------- 1 | # Identity Operations in Python 2 | 3 | ## Introduction 4 | 5 | Identity operators in Python are used to compare the memory locations of two objects to determine if they are the same object or not. The two identity operators are "is" and "is not." 6 | 7 | ## List of Identity Operators 8 | 9 | 1. **is:** Returns `True` if both operands refer to the same object. 10 | 2. **is not:** Returns `True` if both operands refer to different objects. 11 | 12 | ### Examples 13 | 14 | #### is Operator 15 | 16 | ```python 17 | x = [1, 2, 3] 18 | y = x # y now refers to the same object as x 19 | result = x is y 20 | # result will be True 21 | ``` 22 | 23 | #### is not Operator 24 | 25 | ```python 26 | a = "hello" 27 | b = "world" 28 | result = a is not b 29 | # result will be True 30 | ``` 31 | -------------------------------------------------------------------------------- /Day06/notes/Logical: -------------------------------------------------------------------------------- 1 | # Logical Operations in Python 2 | 3 | ## Introduction 4 | 5 | Logical operators in Python are used to manipulate and combine Boolean values. These operators allow you to perform logical operations such as AND, OR, and NOT. 6 | 7 | ## List of Logical Operators 8 | 9 | 1. **AND (and):** Returns `True` if both operands are `True`. 10 | 2. **OR (or):** Returns `True` if at least one of the operands is `True`. 11 | 3. **NOT (not):** Returns the opposite Boolean value of the operand. 12 | 13 | ## Examples 14 | 15 | ### AND Operator 16 | 17 | ```python 18 | x = True 19 | y = False 20 | result = x and y 21 | # result will be False 22 | ``` 23 | 24 | ### OR Operator 25 | 26 | ```python 27 | a = True 28 | b = False 29 | result = a or b 30 | # result will be True 31 | ``` 32 | -------------------------------------------------------------------------------- /Day06/notes/Membership: -------------------------------------------------------------------------------- 1 | # Membership Operations in Python 2 | 3 | ## Introduction 4 | 5 | Membership operators in Python are used to check whether a value is present in a sequence or collection, such as a list, tuple, or string. The membership operators are "in" and "not in." 6 | 7 | ## List of Membership Operators 8 | 9 | 1. **in:** Returns `True` if the left operand is found in the sequence on the right. 10 | 2. **not in:** Returns `True` if the left operand is not found in the sequence on the right. 11 | 12 | ### Examples 13 | 14 | #### in Operator 15 | 16 | ```python 17 | fruits = ["apple", "banana", "cherry"] 18 | result = "banana" in fruits 19 | # result will be True 20 | ``` 21 | 22 | #### not in Operator 23 | 24 | ```python 25 | colors = ["red", "green", "blue"] 26 | result = "yellow" not in colors 27 | # result will be True 28 | ``` 29 | -------------------------------------------------------------------------------- /Day06/notes/Precedence: -------------------------------------------------------------------------------- 1 | # Precedence of Operations in Python 2 | 3 | ## Introduction 4 | 5 | Precedence of operations in Python defines the order in which different types of operators are evaluated in an expression. Operators with higher precedence are evaluated first. 6 | 7 | ## Examples 8 | 9 | ### Arithmetic Precedence 10 | 11 | ```python 12 | result = 5 + 3 * 2 13 | # Multiplication has higher precedence, so result is 11, not 16 14 | ``` 15 | -------------------------------------------------------------------------------- /Day06/notes/Relational: -------------------------------------------------------------------------------- 1 | # Relational Operations in Python 2 | 3 | ## Introduction 4 | 5 | Relational operators in Python are used to compare two values and determine the relationship between them. These operators return a Boolean result, which is either `True` or `False`. 6 | 7 | ## List of Relational Operators 8 | 9 | 1. **Equal to (==):** Checks if two values are equal. 10 | 11 | 2. **Not equal to (!=):** Checks if two values are not equal. 12 | 13 | 3. **Greater than (>):** Checks if the left operand is greater than the right operand. 14 | 15 | 4. **Less than (<):** Checks if the left operand is less than the right operand. 16 | 17 | 5. **Greater than or equal to (>=):** Checks if the left operand is greater than or equal to the right operand. 18 | 19 | 6. **Less than or equal to (<=):** Checks if the left operand is less than or equal to the right operand. 20 | 21 | ## Examples 22 | 23 | ### Equal to 24 | 25 | ```python 26 | a = 5 27 | b = 5 28 | result = a == b 29 | # result will be True 30 | ``` 31 | 32 | ### Not equal to 33 | 34 | ```python 35 | x = 10 36 | y = 7 37 | result = x != y 38 | # result will be True 39 | ``` 40 | -------------------------------------------------------------------------------- /Day07/README.md: -------------------------------------------------------------------------------- 1 | # Conditional Statements in Python 2 | 3 | Conditional statements are a fundamental part of programming that allow you to make decisions and execute different blocks of code based on certain conditions. In Python, you can use `if`, `elif` (short for "else if"), and `else` to create conditional statements. 4 | 5 | ## `if` Statement 6 | 7 | The `if` statement is used to execute a block of code if a specified condition is `True`. If the condition is `False`, the code block is skipped. 8 | 9 | ```python 10 | if condition: 11 | # Code to execute if the condition is True 12 | ``` 13 | 14 | - Example: 15 | 16 | ```python 17 | x = 10 18 | if x > 5: 19 | print("x is greater than 5") 20 | ``` 21 | 22 | ## `elif` Statement 23 | 24 | The `elif` statement allows you to check additional conditions if the previous `if` or `elif` conditions are `False`. You can have multiple `elif` statements after the initial `if` statement. 25 | 26 | ```python 27 | if condition1: 28 | # Code to execute if condition1 is True 29 | elif condition2: 30 | # Code to execute if condition2 is True 31 | elif condition3: 32 | # Code to execute if condition3 is True 33 | # ... 34 | else: 35 | # Code to execute if none of the conditions are True 36 | ``` 37 | 38 | - Example: 39 | 40 | ```python 41 | x = 10 42 | if x > 15: 43 | print("x is greater than 15") 44 | elif x > 5: 45 | print("x is greater than 5 but not greater than 15") 46 | else: 47 | print("x is not greater than 5") 48 | ``` 49 | 50 | ## `else` Statement 51 | 52 | The `else` statement is used to specify a block of code to execute when none of the previous conditions (in the `if` and `elif` statements) are `True`. 53 | 54 | ```python 55 | if condition: 56 | # Code to execute if the condition is True 57 | else: 58 | # Code to execute if the condition is False 59 | ``` 60 | 61 | - Example: 62 | 63 | ```python 64 | x = 3 65 | if x > 5: 66 | print("x is greater than 5") 67 | else: 68 | print("x is not greater than 5") 69 | ``` 70 | -------------------------------------------------------------------------------- /Day07/conditions.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | type = sys.argv[1] 4 | 5 | 6 | if type == "t2.medium": 7 | print ("OK, we will create instance for you") 8 | 9 | else: 10 | print("your input is not t2.medium, we cannot create") 11 | -------------------------------------------------------------------------------- /Day07/somcond.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | type = sys.argv[1] 4 | 5 | if type == "t2.medium": 6 | print ("It will charge you 4 dollars a day") 7 | 8 | elif type == "t2.mlarge": 9 | print ("It will charge you 14 dollars a day") 10 | 11 | elif type == "t2.extralarge": 12 | print ("It will charge you 140 dollars a day") 13 | 14 | elif type == "t2.xxlarge": 15 | print ("It will charge you 300 dollars a day") 16 | 17 | elif type == "t2.micro": 18 | print ("It will charge you 2 dollars a day") 19 | 20 | else: 21 | print ("Please provide a valid instance type") 22 | 23 | 24 | # Here we are passing more conditions by using if, elif, else. 25 | -------------------------------------------------------------------------------- /Day08/assgn/01-lists.py: -------------------------------------------------------------------------------- 1 | # For lists we are using only square braces. 2 | # List is "mutable", 3 | # if we will changed like increased or decreased elements 4 | 5 | 6 | s3_buckets_name = ["abhi", "shek", "veera", "mala"] 7 | 8 | print (s3_buckets_name) 9 | 10 | 11 | 12 | 13 | # By checking classes: we can use type 14 | # in print(type(s3_buckets_name)) 15 | 16 | -------------------------------------------------------------------------------- /Day08/assgn/02-tupels.py: -------------------------------------------------------------------------------- 1 | # For tuples we are using only normal braces. 2 | # List is "im-mutable", 3 | # if can not be changed, like increased or decreased elements 4 | 5 | 6 | s3_buckets_name = ("abhi", "shek", "veera", "mala") 7 | 8 | print (s3_buckets_name) 9 | 10 | 11 | 12 | 13 | # By checking classes: we can use type 14 | # in print(type(s3_buckets_name)) 15 | -------------------------------------------------------------------------------- /Day08/assgn/03-lists_append_remove.py: -------------------------------------------------------------------------------- 1 | # For lists we are using only square braces. In this session append or remove an element/string 2 | # List is "mutable", 3 | # if we will changed like increased or decreased elements 4 | 5 | 6 | s3_buckets_name = ["abhi", "shek", "veera", "mala"] 7 | # s3_buckets_name.append("youtuber") 8 | 9 | 10 | 11 | print (s3_buckets_name) 12 | 13 | 14 | # By removing any element/string we can use remove function 15 | 16 | # s3_buckets_name.remove("mala") 17 | # print (s3_buckets_name) 18 | 19 | -------------------------------------------------------------------------------- /Day08/assgn/04-00-list-questions.md: -------------------------------------------------------------------------------- 1 | # Basic-Level List Questions 2 | 3 | **Q1: What is a list in Python, and how is it used in DevOps?** 4 | 5 | **Q2: How do you create a list in Python, and can you provide an example related to DevOps?** 6 | 7 | **Q3: What is the difference between a list and a tuple in Python, and when would you choose one over the other in a DevOps context?** 8 | 9 | **Q4: How can you access elements in a list, and provide a DevOps-related example?** 10 | 11 | **Q5: How do you add an element to the end of a list in Python? Provide a DevOps example.** 12 | 13 | **Q6: How can you remove an element from a list in Python, and can you provide a DevOps use case?** 14 | 15 | -------------------------------------------------------------------------------- /Day08/assgn/04-01-list-answers.md: -------------------------------------------------------------------------------- 1 | # Basic-Level List Answers 2 | 3 | **Q1: What is a list in Python, and how is it used in DevOps?** 4 | A list in Python is a collection of ordered and mutable elements. In DevOps, lists are often used to manage and manipulate data, such as configurations, server names, and deployment targets. For example, you can use a list to store a list of servers that need to be provisioned or configured. 5 | 6 | **Q2: How do you create a list in Python, and can you provide an example related to DevOps?** 7 | In Python, you create a list using square brackets `[]`. Here's an example related to DevOps: 8 | ```python 9 | servers = ['web-server-01', 'db-server-01', 'app-server-01'] 10 | ``` 11 | 12 | **Q3: What is the difference between a list and a tuple in Python, and when would you choose one over the other in a DevOps context?** 13 | The key difference is mutability; lists are mutable, while tuples are immutable. In DevOps, if you need a collection of items that won't change (e.g., server configurations, deployment steps), you would use a tuple. If the data can change (e.g., a list of active servers, configuration settings that may be updated), you would use a list. 14 | 15 | **Q4: How can you access elements in a list, and provide a DevOps-related example?** 16 | You can access elements in a list by using their index. In a DevOps context, if you have a list of server names and want to access the first server, you would do the following: 17 | ```python 18 | servers = ['web-server-01', 'db-server-01', 'app-server-01'] 19 | first_server = servers[0] 20 | ``` 21 | 22 | **Q5: How do you add an element to the end of a list in Python? Provide a DevOps example.** 23 | You can add an element to the end of a list using the `append()` method. In DevOps, if you want to add a new server to a list of servers, you can do this: 24 | ```python 25 | servers = ['web-server-01', 'db-server-01'] 26 | servers.append('app-server-01') 27 | ``` 28 | 29 | **Q6: How can you remove an element from a list in Python, and can you provide a DevOps use case?** 30 | You can remove an element from a list using the `remove()` method. In a DevOps use case, you might want to remove a server from a list of servers that are no longer needed: 31 | ```python 32 | servers = ['web-server-01', 'db-server-01', 'app-server-01'] 33 | servers.remove('db-server-01') 34 | ``` 35 | -------------------------------------------------------------------------------- /Day08/assgn/sort_mechanism.py: -------------------------------------------------------------------------------- 1 | numbers = [1, 21, 8, 69, 102, 85, 98, 4, 22, 100, 85] 2 | 3 | numbers.sort() 4 | 5 | print (numbers) 6 | -------------------------------------------------------------------------------- /Day08/assgn/tounge-catination.py: -------------------------------------------------------------------------------- 1 | s3_buckets_name = ["abhi", "shek", "veera", "mala"] 2 | 3 | print (s3_buckets_name[0] + s3_buckets_name[1]) 4 | 5 | -------------------------------------------------------------------------------- /Day08/assgn/tounge-catination1.py: -------------------------------------------------------------------------------- 1 | s3_buckets_name = ["abhi", "shek", "veera", "mala"] 2 | 3 | print (s3_buckets_name[0] + "--" + s3_buckets_name[1]) 4 | 5 | -------------------------------------------------------------------------------- /Day08/notes/01-list.md: -------------------------------------------------------------------------------- 1 | # Understanding Lists and List Data Structure 2 | 3 | ## What is a List? 4 | A list is a fundamental data structure in programming that allows you to store a collection of items. Lists are ordered and can contain elements of various data types, such as numbers, strings, and objects. 5 | 6 | ## Creating Lists 7 | You can create a list in various programming languages. In Python, for example, you create a list using square brackets: 8 | ```python 9 | my_list = [1, 2, 3, 'apple', 'banana'] 10 | ``` 11 | 12 | ## List Indexing 13 | List elements are indexed, starting from 0 for the first element. You can access elements by their index. 14 | ```python 15 | first_element = my_list[0] # Access the first element (1) 16 | ``` 17 | 18 | ## List Length 19 | You can find the length of a list using the `len()` function. 20 | ```python 21 | list_length = len(my_list) # Length of the list (5) 22 | ``` 23 | 24 | # List Manipulation and Common List Operations 25 | 26 | ## Appending to a List 27 | You can add elements to the end of a list using the `append()` method. 28 | ```python 29 | my_list.append(4) # Adds 4 to the end of the list 30 | ``` 31 | 32 | ## Removing from a List 33 | You can remove elements by their value using the `remove()` method. 34 | ```python 35 | my_list.remove('apple') # Removes 'apple' from the list 36 | ``` 37 | 38 | ## Slicing a List 39 | Slicing allows you to create a new list from a subset of the original list. 40 | ```python 41 | subset = my_list[1:4] # Creates a new list with elements at index 1, 2, and 3 42 | ``` 43 | 44 | ## Concatenating Lists 45 | You can combine two or more lists to create a new list. 46 | ```python 47 | new_list = my_list + [5, 6] # Concatenates my_list with [5, 6] 48 | ``` 49 | 50 | ## Sorting a List 51 | You can sort a list in ascending or descending order using the `sort()` method. 52 | ```python 53 | my_list.sort() # Sorts the list in ascending order 54 | ``` 55 | 56 | ## Checking for an Element 57 | You can check if an element exists in a list using the `in` keyword. 58 | ```python 59 | is_present = 'banana' in my_list # Checks if 'banana' is in the list (True) 60 | ``` 61 | -------------------------------------------------------------------------------- /Day08/notes/02-tuple.md: -------------------------------------------------------------------------------- 1 | # Understanding Tuples 2 | 3 | ## What is a Tuple? 4 | A tuple is a data structure similar to a list, but unlike lists, tuples are immutable, meaning their contents cannot be changed after creation. Tuples are typically used for grouping related data. 5 | 6 | ## Creating Tuples 7 | You can create a tuple in various programming languages. In Python, for example, you create a tuple using parentheses: 8 | ```python 9 | my_tuple = (1, 2, 'apple', 'banana') 10 | ``` 11 | 12 | ## Tuple Indexing 13 | Tuple elements are indexed, starting from 0 for the first element. You can access elements by their index, just like lists. 14 | ```python 15 | first_element = my_tuple[0] # Access the first element (1) 16 | ``` 17 | 18 | ## Tuple Length 19 | You can find the length of a tuple using the `len()` function. 20 | ```python 21 | tuple_length = len(my_tuple) # Length of the tuple (4) 22 | ``` 23 | 24 | # Common Tuple Operations 25 | 26 | ## Accessing Tuple Elements 27 | Tuples are immutable, so you can only access their elements. 28 | ```python 29 | second_element = my_tuple[1] # Access the second element (2) 30 | ``` 31 | 32 | ## Tuple Packing and Unpacking 33 | You can pack multiple values into a tuple and unpack them into separate variables. 34 | ```python 35 | coordinates = (3, 4) 36 | x, y = coordinates # Unpack the tuple into x and y (x=3, y=4) 37 | ``` 38 | 39 | ## Concatenating Tuples 40 | You can concatenate two or more tuples to create a new tuple. 41 | ```python 42 | new_tuple = my_tuple + (3.14, 'cherry') # Concatenates my_tuple with a new tuple 43 | ``` 44 | 45 | ## Checking for an Element 46 | You can check if an element exists in a tuple using the `in` keyword. 47 | ```python 48 | is_present = 'apple' in my_tuple # Checks if 'apple' is in the tuple (True) 49 | ``` 50 | 51 | ## Using Tuples for Multiple Return Values 52 | Tuples are often used to return multiple values from a function. 53 | ```python 54 | def get_coordinates(): 55 | return (3, 4) 56 | 57 | x, y = get_coordinates() # Unpack the returned tuple (x=3, y=4) 58 | ``` 59 | -------------------------------------------------------------------------------- /Day08/notes/03-list-vs-tuple.md: -------------------------------------------------------------------------------- 1 | # Differences Between Tuples and Lists 2 | 3 | Tuples and lists are both common data structures used in programming, but they have some fundamental differences that make them suitable for different purposes. Let's explore these differences: 4 | 5 | ## 1. Mutability 6 | 7 | **List:** Lists are mutable, meaning their elements can be added, removed, or modified after creation. You can use methods like `append()`, `remove()`, and `pop()` to change the contents of a list. 8 | 9 | **Tuple:** Tuples are immutable, and once created, their elements cannot be changed, added, or removed. You can't use methods to modify the tuple. 10 | 11 | ## 2. Syntax 12 | 13 | **List:** Lists are created using square brackets `[ ]`. Elements are separated by commas. 14 | 15 | ```python 16 | my_list = [1, 2, 3, 'apple', 'banana'] 17 | ``` 18 | 19 | **Tuple:** Tuples are created using parentheses `( )`. Elements are also separated by commas. 20 | 21 | ```python 22 | my_tuple = (1, 2, 'apple', 'banana') 23 | ``` 24 | 25 | ## 3. Performance 26 | 27 | **List:** Lists may have slightly slower performance compared to tuples because they are mutable. Modifying a list requires memory reallocation, which can be slower for large lists. 28 | 29 | **Tuple:** Tuples have better performance, especially for read-only operations, because of their immutability. They do not require memory reallocation. 30 | 31 | ## 4. Use Cases 32 | 33 | **List:** Lists are used when you need a collection of elements that can change, such as a dynamic list of items or data that needs to be modified. 34 | 35 | **Tuple:** Tuples are used when you need an ordered collection of elements that should not change, such as representing a point in 2D space (x, y), or when you want to ensure the integrity of the data. 36 | 37 | ## 5. Iteration 38 | 39 | **List:** You can use a for loop or other iteration methods to iterate over the elements of a list. 40 | 41 | ```python 42 | for item in my_list: 43 | # Process each item 44 | ``` 45 | 46 | **Tuple:** You can iterate over the elements of a tuple in the same way as lists using a for loop. 47 | 48 | ```python 49 | for item in my_tuple: 50 | # Process each item 51 | ``` 52 | 53 | ## 6. Memory Usage 54 | 55 | **List:** Lists generally consume more memory than tuples because they need to store additional information to support their mutability. 56 | 57 | **Tuple:** Tuples consume less memory because they are immutable, and the interpreter can optimize memory usage. 58 | 59 | -------------------------------------------------------------------------------- /Day08/notes/04-faq.md: -------------------------------------------------------------------------------- 1 | **Q1: What is a list in Python, and how is it used in DevOps?** 2 | 3 | *Answer:* 4 | A list in Python is a collection of ordered and mutable elements. In DevOps, lists are often used to manage and manipulate data, such as configurations, server names, and deployment targets. For example, you can use a list to store a list of servers that need to be provisioned or configured. 5 | 6 | **Q2: How do you create a list in Python, and can you provide an example related to DevOps?** 7 | 8 | *Answer:* 9 | In Python, you create a list using square brackets `[]`. Here's an example related to DevOps: 10 | 11 | ```python 12 | servers = ['web-server-01', 'db-server-01', 'app-server-01'] 13 | ``` 14 | 15 | This list can be used to represent a list of servers in a DevOps environment. 16 | 17 | **Q3: What is the difference between a list and a tuple in Python, and when would you choose one over the other in a DevOps context?** 18 | 19 | *Answer:* 20 | The key difference is mutability; lists are mutable, while tuples are immutable. In DevOps, if you need a collection of items that won't change (e.g., server configurations, deployment steps), you would use a tuple. If the data can change (e.g., a list of active servers, configuration settings that may be updated), you would use a list. 21 | 22 | **Q4: How can you access elements in a list, and provide a DevOps-related example?** 23 | 24 | *Answer:* 25 | You can access elements in a list by using their index. In a DevOps context, if you have a list of server names and want to access the first server, you would do the following: 26 | 27 | ```python 28 | servers = ['web-server-01', 'db-server-01', 'app-server-01'] 29 | first_server = servers[0] 30 | ``` 31 | 32 | **Q5: How do you add an element to the end of a list in Python? Provide a DevOps example.** 33 | 34 | *Answer:* 35 | You can add an element to the end of a list using the `append()` method. In DevOps, if you want to add a new server to a list of servers, you can do this: 36 | 37 | ```python 38 | servers = ['web-server-01', 'db-server-01'] 39 | servers.append('app-server-01') 40 | ``` 41 | 42 | Now, `servers` will contain 'app-server-01'. 43 | 44 | **Q6: How can you remove an element from a list in Python, and can you provide a DevOps use case?** 45 | 46 | *Answer:* 47 | You can remove an element from a list using the `remove()` method. In a DevOps use case, you might want to remove a server from a list of servers that are no longer needed: 48 | 49 | ```python 50 | servers = ['web-server-01', 'db-server-01', 'app-server-01'] 51 | servers.remove('db-server-01') 52 | ``` 53 | -------------------------------------------------------------------------------- /Day09/assgn/loop-00-exp.py: -------------------------------------------------------------------------------- 1 | # Here we can write loops, in this loops we have two types: 2 | # for loop and while loop 3 | # In this example am writing for loop 4 | # key words like for, i, range 5 | 6 | 7 | for i in range(10): 8 | print("abhishek") 9 | print("veeramalla") 10 | 11 | 12 | -------------------------------------------------------------------------------- /Day09/assgn/loop-01-exp.py: -------------------------------------------------------------------------------- 1 | for i in range(10): 2 | print(i) 3 | -------------------------------------------------------------------------------- /Day09/assgn/loop-02-exp.py: -------------------------------------------------------------------------------- 1 | colors = ["yellow", "green", "blue"] 2 | 3 | for x in colors: 4 | print(x) 5 | -------------------------------------------------------------------------------- /Day09/assgn/loop-03-exp.py: -------------------------------------------------------------------------------- 1 | colors = ["yellow", "green", "blue"] 2 | 3 | for y in range(10): 4 | print(y) 5 | 6 | -------------------------------------------------------------------------------- /Day09/assgn/loop-04-exp.py: -------------------------------------------------------------------------------- 1 | colors = ["yellow", "green", "blue"] 2 | numbers = [1, 2, 3, 4, 5, 6] 3 | 4 | for y in colors: 5 | print(y) 6 | 7 | -------------------------------------------------------------------------------- /Day09/assgn/loop-05-exp.py: -------------------------------------------------------------------------------- 1 | colors = ["yellow", "green", "blue"] 2 | numbers = [1, 2, 3, 4, 5, 6] 3 | 4 | for y in range(6): 5 | print(y) 6 | -------------------------------------------------------------------------------- /Day09/assgn/loop-break.py: -------------------------------------------------------------------------------- 1 | numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 2 | 3 | for number in numbers: 4 | if number == 3: 5 | break 6 | print(number) 7 | -------------------------------------------------------------------------------- /Day09/assgn/loop-continue.py: -------------------------------------------------------------------------------- 1 | numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 2 | 3 | for number in numbers: 4 | if number == 3: 5 | continue 6 | print(number) 7 | -------------------------------------------------------------------------------- /Day09/assgn/while.py: -------------------------------------------------------------------------------- 1 | while kubectl get deployment/myapp | grep -q 0/1; do 2 | echo "Waiting for myapp to be ready..." 3 | sleep 10 4 | done 5 | 6 | 7 | 8 | # If this loop am writing only for understand, it did not execute as of now. we dont have k8s conditions now 9 | -------------------------------------------------------------------------------- /Day09/notes/01-loops.md: -------------------------------------------------------------------------------- 1 | # Loops in Python (for and while) 2 | 3 | ## Introduction 4 | 5 | Loops are a fundamental concept in programming, and they allow you to perform repetitive tasks efficiently. In Python, there are two primary types of loops: "for" and "while." 6 | 7 | ## For Loop 8 | 9 | The "for" loop is used to iterate over a sequence (such as a list, tuple, string, or range) and execute a set of statements for each item in the sequence. The loop continues until all items in the sequence have been processed. 10 | 11 | **Syntax:** 12 | 13 | ```python 14 | for variable in sequence: 15 | # Code to be executed for each item in the sequence 16 | ``` 17 | 18 | **Example:** 19 | 20 | ```python 21 | fruits = ["apple", "banana", "cherry"] 22 | for fruit in fruits: 23 | print(fruit) 24 | ``` 25 | 26 | **Output:** 27 | 28 | ``` 29 | apple 30 | banana 31 | cherry 32 | ``` 33 | 34 | In this example, the loop iterates over the "fruits" list, and in each iteration, the "fruit" variable takes on the value of the current item in the list. 35 | 36 | #### While Loop 37 | 38 | The "while" loop continues to execute a block of code as long as a specified condition is true. It's often used when you don't know in advance how many times the loop should run. 39 | 40 | **Syntax:** 41 | 42 | ```python 43 | while condition: 44 | # Code to be executed as long as the condition is true 45 | ``` 46 | 47 | **Example:** 48 | 49 | ```python 50 | count = 0 51 | while count < 5: 52 | print(count) 53 | count += 1 54 | ``` 55 | 56 | **Output:** 57 | 58 | ``` 59 | 0 60 | 1 61 | 2 62 | 3 63 | 4 64 | ``` 65 | 66 | In this example, the "while" loop continues to execute as long as the "count" is less than 5. The "count" variable is incremented in each iteration. 67 | -------------------------------------------------------------------------------- /Day09/notes/02-loop-controls.md: -------------------------------------------------------------------------------- 1 | # Loop Control Statements (break and continue) 2 | 3 | ## Introduction 4 | 5 | Loop control statements are used to modify the behavior of loops, providing greater control and flexibility during iteration. In Python, two primary loop control statements are "break" and "continue." 6 | 7 | ## `break` Statement 8 | 9 | The "break" statement is used to exit the loop prematurely. It can be applied to both "for" and "while" loops, allowing you to terminate the loop when a particular condition is met. 10 | 11 | **Example:** 12 | 13 | ```python 14 | numbers = [1, 2, 3, 4, 5] 15 | for number in numbers: 16 | if number == 3: 17 | break 18 | print(number) 19 | ``` 20 | 21 | **Output:** 22 | 23 | ``` 24 | 1 25 | 2 26 | ``` 27 | 28 | In this example, the loop stops when it encounters the number 3. 29 | 30 | ## `continue` Statement 31 | 32 | The "continue" statement is used to skip the current iteration of the loop and proceed to the next one. It can be used in both "for" and "while" loops, enabling you to bypass certain iterations based on a condition. 33 | 34 | **Example:** 35 | 36 | ```python 37 | numbers = [1, 2, 3, 4, 5] 38 | for number in numbers: 39 | if number == 3: 40 | continue 41 | print(number) 42 | ``` 43 | 44 | **Output:** 45 | 46 | ``` 47 | 1 48 | 2 49 | 4 50 | 5 51 | ``` 52 | 53 | In this example, the loop skips the iteration where the number is 3 and continues with the next iteration. 54 | 55 | ## Practice Exercise - Automating Log File Analysis 56 | 57 | #### Introduction 58 | 59 | In this practice exercise, we use a "for" loop to automate the analysis of a log file and identify lines containing the word "error." This demonstrates how loops can be used to process data and extract relevant information efficiently. 60 | 61 | **Example:** 62 | 63 | ```python 64 | log_file = [ 65 | "INFO: Operation successful", 66 | "ERROR: File not found", 67 | "DEBUG: Connection established", 68 | "ERROR: Database connection failed", 69 | ] 70 | 71 | for line in log_file: 72 | if "ERROR" in line: 73 | print(line) 74 | ``` 75 | 76 | **Output:** 77 | 78 | ``` 79 | ERROR: File not found 80 | ERROR: Database connection failed 81 | ``` 82 | 83 | In this exercise, the loop iterates through the "log_file" list and prints lines containing the word "ERROR." 84 | -------------------------------------------------------------------------------- /Day09/notes/03-for-loop-devops-usecases.md: -------------------------------------------------------------------------------- 1 | # For Loop DevOps use-cases 2 | 3 | 1. **Server Provisioning and Configuration:** 4 | 5 | DevOps engineers use "for" loops when provisioning multiple servers or virtual machines with the same configuration. For example, when setting up monitoring agents on multiple servers: 6 | 7 | ```bash 8 | servers=("server1" "server2" "server3") 9 | for server in "${servers[@]}"; do 10 | configure_monitoring_agent "$server" 11 | done 12 | ``` 13 | 14 | 2. **Deploying Configurations to Multiple Environments:** 15 | 16 | When deploying configurations to different environments (e.g., development, staging, production), DevOps engineers can use a "for" loop to apply the same configuration changes to each environment: 17 | 18 | ```bash 19 | environments=("dev" "staging" "prod") 20 | for env in "${environments[@]}"; do 21 | deploy_configuration "$env" 22 | done 23 | ``` 24 | 25 | 3. **Backup and Restore Operations:** 26 | 27 | Automating backup and restore operations is a common use case. DevOps engineers can use "for" loops to create backups for multiple databases or services and later restore them as needed. 28 | 29 | ```bash 30 | databases=("db1" "db2" "db3") 31 | for db in "${databases[@]}"; do 32 | create_backup "$db" 33 | done 34 | ``` 35 | 36 | 4. **Log Rotation and Cleanup:** 37 | 38 | DevOps engineers use "for" loops to manage log files, rotate logs, and clean up older log files to save disk space. 39 | 40 | ```bash 41 | log_files=("app.log" "access.log" "error.log") 42 | for log_file in "${log_files[@]}"; do 43 | rotate_and_cleanup_logs "$log_file" 44 | done 45 | ``` 46 | 47 | 5. **Monitoring and Reporting:** 48 | 49 | In scenarios where you need to gather data or perform checks on multiple systems, a "for" loop is handy. For example, monitoring server resources across multiple machines: 50 | 51 | ```bash 52 | servers=("server1" "server2" "server3") 53 | for server in "${servers[@]}"; do 54 | check_resource_utilization "$server" 55 | done 56 | ``` 57 | 58 | 6. **Managing Cloud Resources:** 59 | 60 | When working with cloud infrastructure, DevOps engineers can use "for" loops to manage resources like virtual machines, databases, and storage across different cloud providers. 61 | 62 | ```bash 63 | instances=("instance1" "instance2" "instance3") 64 | for instance in "${instances[@]}"; do 65 | resize_instance "$instance" 66 | done 67 | ``` 68 | -------------------------------------------------------------------------------- /Day09/notes/04-while-loop-devops-usecases.md: -------------------------------------------------------------------------------- 1 | # While Loop DevOps Usecases 2 | 3 | DevOps engineers often use "while" loops in various real-time use cases to automate, monitor, and manage infrastructure and deployments. Here are some practical use cases from a DevOps engineer's perspective: 4 | 5 | 1. **Continuous Integration/Continuous Deployment (CI/CD) Pipeline:** 6 | 7 | DevOps engineers often use "while" loops in CI/CD pipelines to monitor the deployment status of applications. They can create a "while" loop that periodically checks the status of a deployment or a rolling update until it completes successfully or fails. For example, waiting for a certain number of pods to be ready in a Kubernetes deployment: 8 | 9 | ```bash 10 | while kubectl get deployment/myapp | grep -q 0/1; do 11 | echo "Waiting for myapp to be ready..." 12 | sleep 10 13 | done 14 | ``` 15 | 16 | 2. **Provisioning and Scaling Cloud Resources:** 17 | 18 | When provisioning or scaling cloud resources, DevOps engineers may use "while" loops to wait for the resources to be fully provisioned and ready. For instance, waiting for an Amazon EC2 instance to become available: 19 | 20 | ```bash 21 | while ! aws ec2 describe-instance-status --instance-ids i-1234567890abcdef0 | grep -q "running"; do 22 | echo "Waiting for the EC2 instance to be running..." 23 | sleep 10 24 | done 25 | ``` 26 | 27 | 3. **Log Analysis and Alerting:** 28 | 29 | DevOps engineers can use "while" loops to continuously monitor logs for specific events or errors and trigger alerts when a certain condition is met. For example, tailing a log file and alerting when an error is detected: 30 | 31 | ```bash 32 | while true; do 33 | if tail -n 1 /var/log/app.log | grep -q "ERROR"; then 34 | send_alert "Error detected in the log." 35 | fi 36 | sleep 5 37 | done 38 | ``` 39 | 40 | 4. **Database Replication and Data Synchronization:** 41 | 42 | DevOps engineers use "while" loops to monitor database replication and ensure data consistency across multiple database instances. The loop can check for replication lag and trigger corrective actions when necessary. 43 | 44 | ```bash 45 | while true; do 46 | replication_lag=$(mysql -e "SHOW SLAVE STATUS\G" | grep "Seconds_Behind_Master" | awk '{print $2}') 47 | if [ "$replication_lag" -gt 60 ]; then 48 | trigger_data_sync 49 | fi 50 | sleep 60 51 | done 52 | ``` 53 | 54 | 5. **Service Health Monitoring and Auto-Recovery:** 55 | 56 | DevOps engineers can use "while" loops to continuously check the health of services and automatically trigger recovery actions when services become unhealthy. 57 | 58 | ```bash 59 | while true; do 60 | if ! check_service_health; then 61 | restart_service 62 | fi 63 | sleep 30 64 | done 65 | ``` 66 | 67 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # python-for-devops-practices 2 | reference for "https://github.com/iam-veeramalla/python-for-devops/tree/main" 3 | 4 | 5 | 6 | 7 | # Python Zero to Hero for DevOps Engineers 8 | 9 | 10 | 11 | ## Day 1: Introduction to Python, Installation, and Configuration 12 | - Introduction to Python and its role in DevOps. 13 | - Installing Python and setting up a development environment. 14 | - Writing your first Python program. 15 | 16 | ## Day 2: Intro to Datatypes, Working with Strings and Numbers 17 | - String data type in Python. 18 | - String manipulation and formatting. 19 | - Regular expressions for text processing. 20 | - Numeric data types in Python (int, float). 21 | 22 | ## Day 3: Keywords and Variables 23 | - Understanding variables in Python. 24 | - Variable scope and lifetime. 25 | - Variable naming conventions and best practices. 26 | - Practice exercises and examples: 27 | - Example: Using variables to store and manipulate configuration data in a DevOps context. 28 | 29 | ## Day 4: Functions, Modules and Packages 30 | - What are differences between function, modules and packages ? 31 | - How to import a package ? 32 | - What are Python workspaces ? 33 | 34 | ## Day 5: Environment Variables and Command Line Arguments 35 | - Reading and writing environment variables in Python. 36 | - Using the os and dotenv modules. 37 | - Securing sensitive information in environment variables. 38 | - Handling command line arguments in Python. 39 | - Practice exercises and examples: 40 | - Example: Developing a Python script that accepts command line arguments to customize DevOps automation tasks. 41 | 42 | ## Day 6: Operators 43 | - Introduction to operators in Python. 44 | - Arithmetic, comparison, and logical operators. 45 | - Bitwise and assignment operators. 46 | - Practice exercises and examples: 47 | - Example: Using operators to perform calculations and comparisons in a DevOps script. 48 | 49 | ## Day 7: Conditional Handling using if, elif and else 50 | - Conditional statements (if, elif, else). 51 | - Practice exercises and examples: 52 | 53 | ## Day 8: Working with Lists (Part 1) 54 | - Understanding lists and list data structure. 55 | - List manipulation and common list operations. 56 | - Practice exercises and examples: 57 | - Example: Writing a script to manage a list of user accounts in a DevOps environment. 58 | 59 | ## Day 9: Loops 60 | - Loops in Python (for and while). 61 | - Loop control statements (break, continue). 62 | - Practice exercises and examples: 63 | - Example: Automating a log file analysis with a loop to find errors. 64 | 65 | ## Day 10: Working with Lists (Part 2) 66 | - List comprehensions. 67 | - Nested lists and advanced list operations. 68 | - Practice exercises and examples: 69 | - Example: Parsing a complex configuration file with nested lists. 70 | 71 | ## Day 11: Working with Dictionaries and Sets 72 | - Dictionaries and key-value pairs. 73 | - Sets and set operations. 74 | - Practice exercises and examples: 75 | - Example: Managing a dictionary of server configurations and optimizing retrieval. 76 | 77 | ## Day 12: Functions and Modules 78 | - Introduction to functions in Python. 79 | - Writing functions and function parameters. 80 | - Return values and modular code. 81 | - Practice exercises and examples: 82 | - Example: Creating a function to automate server status checks. 83 | 84 | ## Day 13: Functions and Modules (Part 2) 85 | - Advanced function topics (recursion, lambda functions). 86 | - Function libraries and built-in functions. 87 | - Practice exercises and examples: 88 | - Example: Developing a library of custom functions for DevOps automation. 89 | 90 | ## Day 14: Python Libraries for DevOps (Part 1) 91 | - Introduction to external libraries like Paramiko, Fabric, and Boto3. 92 | - Automating SSH connections with Paramiko. 93 | - Running commands on remote servers. 94 | - Practice exercises and examples: 95 | - Example: Using Paramiko to create a secure remote backup solution. 96 | 97 | ## Day 15: Python Libraries for DevOps (Part 2) 98 | - Using Fabric for remote task automation. 99 | - AWS automation with Boto3. 100 | - Managing EC2 instances, S3 buckets, and more. 101 | - Practice exercises and examples: 102 | - Example: Creating a Fabric script for deploying applications to remote servers. 103 | 104 | ## Day 16: Working with RESTful APIs 105 | - Introduction to RESTful APIs. 106 | - Making HTTP requests using Python. 107 | - Parsing JSON responses and error handling. 108 | - Practice exercises and examples: 109 | - Example: Developing a script to monitor RESTful API endpoints for your DevOps tools. 110 | 111 | ## Day 17: Data Serialization and Configuration Files 112 | - Serializing and deserializing data (JSON, YAML). 113 | - Managing configuration data. 114 | - DevOps use cases for configuration files. 115 | - Practice exercises and examples: 116 | - Example: Building a configuration manager to handle application settings in JSON format. 117 | 118 | ## Day 18: Automation with Cron Jobs 119 | - Scheduling automated tasks using cron. 120 | - Creating Python scripts for scheduled automation. 121 | - Handling periodic tasks and reports. 122 | - Practice exercises and examples: 123 | - Example: Using cron and Python to schedule regular backups of your data. 124 | 125 | ## Day 19: Python Interview Questions & Answers 126 | 127 | --------------------------------------------------------------------------------