Skip to content

Commit fabfc75

Browse files
authored
Merge pull request #1 from iam-veeramalla/main
day 1
2 parents 22f33a3 + 2a8028b commit fabfc75

25 files changed

+357
-2
lines changed

Day-01/01-shell-vs-python.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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.

Day-01/02-hello-world.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("Hello, World!")

Day-02/01-data-types.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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.

Day-02/02-strings.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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()`.

Day-02/03-numeric.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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.

Day-02/04-regex.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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.

Day-02/examples/01-string-concat.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
str1 = "Hello"
2+
str2 = "World"
3+
result = str1 + " " + str2
4+
print(result)

Day-02/examples/01-string-len.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
text = "Python is awesome"
2+
length = len(text)
3+
print("Length of the string:", length)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
text = "Python is awesome"
2+
uppercase = text.upper()
3+
lowercase = text.lower()
4+
print("Uppercase:", uppercase)
5+
print("Lowercase:", lowercase)

Day-02/examples/01-string-replace.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
text = "Python is awesome"
2+
new_text = text.replace("awesome", "great")
3+
print("Modified text:", new_text)

0 commit comments

Comments
 (0)