Skip to content

Commit af74ab9

Browse files
Merge branch 'iam-veeramalla:main' into main
2 parents b064469 + 7a2982a commit af74ab9

File tree

6 files changed

+334
-17
lines changed

6 files changed

+334
-17
lines changed

Day-14/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Github-JIRA intergration Project

Day-15/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Github-JIRA intergration Project - (Part-2)

Day-15/examples/hello-world.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from flask import Flask
2+
3+
app = Flask(__name__)
4+
5+
@app.route('/')
6+
def hello_world():
7+
return 'Hello, World!'
8+
9+
if __name__ == '__main__':
10+
app.run("0.0.0.0")

Day-15/github-jira.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# This code sample uses the 'requests' library:
2+
# http://docs.python-requests.org
3+
import requests
4+
from requests.auth import HTTPBasicAuth
5+
import json
6+
from flask import Flask
7+
8+
app = Flask(__name__)
9+
10+
# Define a route that handles GET requests
11+
@app.route('/createJira', methods=['POST'])
12+
def createJira():
13+
14+
url = "https://veeramallaabhishek.atlassian.net/rest/api/3/issue"
15+
16+
API_TOKEN=""
17+
18+
auth = HTTPBasicAuth("", API_TOKEN)
19+
20+
headers = {
21+
"Accept": "application/json",
22+
"Content-Type": "application/json"
23+
}
24+
25+
payload = json.dumps( {
26+
"fields": {
27+
"description": {
28+
"content": [
29+
{
30+
"content": [
31+
{
32+
"text": "Order entry fails when selecting supplier.",
33+
"type": "text"
34+
}
35+
],
36+
"type": "paragraph"
37+
}
38+
],
39+
"type": "doc",
40+
"version": 1
41+
},
42+
"project": {
43+
"key": "AB"
44+
},
45+
"issuetype": {
46+
"id": "10006"
47+
},
48+
"summary": "Main order flow broken",
49+
},
50+
"update": {}
51+
} )
52+
53+
54+
response = requests.request(
55+
"POST",
56+
url,
57+
data=payload,
58+
headers=headers,
59+
auth=auth
60+
)
61+
62+
return json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": "))
63+
64+
if __name__ == '__main__':
65+
app.run(host='0.0.0.0', port=5000)

Day-16/README.md

Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
# Interview Questions (Beginner and Intermediate)
2+
3+
## Describe a real-world example of how you used Python to solve a DevOps challenge.
4+
5+
- Here you can talk about the projects that we did in this series
6+
- GitHub Webhooks
7+
- JIRA integration
8+
- File Operations
9+
10+
## Discuss the challenges that you faced while using Python for DevOps and how did you overcome it.
11+
12+
- Here you can mention about a challenge that you faced while implementating a Python project for DevOps that we learnt.
13+
14+
## How can you secure your Python code and scripts?
15+
16+
- Handle any sensetive information using Input variables, command line arguments or env vars.
17+
18+
## Explain the difference between mutable and immutable objects.
19+
20+
In Python, mutable objects can be altered after creation, while immutable objects cannot be changed once created. For instance:
21+
22+
Mutable objects like lists can be modified:
23+
24+
```
25+
my_list = [1, 2, 3]
26+
my_list[0] = 0 # Modifying an element in the list
27+
print(my_list) # Output: [0, 2, 3]
28+
```
29+
30+
Immutable objects like tuples cannot be altered:
31+
32+
```
33+
my_tuple = (1, 2, 3)
34+
# Attempting to change a tuple will result in an error
35+
# my_tuple[0] = 0
36+
```
37+
38+
## Differentiate between list and tuple in Python.
39+
40+
Lists are mutable and typically used for storing collections of items that can be changed, while tuples are immutable and commonly used to store collections of items that shouldn't change. Examples:
41+
42+
List:
43+
44+
```
45+
my_list = [1, 2, 3]
46+
my_list.append(4) # Modifying by adding an element
47+
print(my_list) # Output: [1, 2, 3, 4]
48+
```
49+
50+
Tuple:
51+
52+
```
53+
my_tuple = (1, 2, 3)
54+
# Attempting to modify a tuple will result in an error
55+
# my_tuple.append(4)
56+
```
57+
58+
## Explain the use of virtualenv.
59+
60+
Virtualenv creates isolated Python environments, allowing different projects to use different versions of packages without conflicts. Example:
61+
62+
Creating a virtual environment:
63+
64+
### Creating a virtual environment named 'myenv'
65+
virtualenv myenv
66+
67+
Activating the virtual environment:
68+
69+
### On Windows
70+
```
71+
myenv\Scripts\activate
72+
```
73+
74+
### On Unix or MacOS
75+
```
76+
source myenv/bin/activate
77+
```
78+
79+
## What are decorators in Python?
80+
81+
Decorators modify the behavior of functions. They take a function as an argument, add some functionality, and return another function without modifying the original function's code. Example:
82+
83+
Defining a simple decorator:
84+
85+
```
86+
def my_decorator(func):
87+
def wrapper():
88+
print("Something is happening before the function is called.")
89+
func()
90+
print("Something is happening after the function is called.")
91+
return wrapper
92+
93+
@my_decorator
94+
def say_hello():
95+
print("Hello!")
96+
97+
say_hello()
98+
```
99+
100+
## How does exception handling work in Python?
101+
102+
Exception handling in Python uses try, except, else, and finally blocks. Example:
103+
104+
Handling division by zero exception:
105+
106+
```
107+
try:
108+
result = 10 / 0
109+
except ZeroDivisionError:
110+
print("Division by zero is not allowed.")
111+
else:
112+
print("Division successful:", result)
113+
finally:
114+
print("Execution completed.")
115+
```
116+
117+
## What's the difference between append() and extend() for lists?
118+
119+
append() adds a single element to the end of a list, while extend() adds multiple elements by appending elements from an iterable. Example:
120+
121+
Using append():
122+
```
123+
my_list = [1, 2, 3]
124+
my_list.append(4)
125+
print(my_list) # Output: [1, 2, 3, 4]
126+
```
127+
128+
Using extend():
129+
130+
```
131+
my_list = [1, 2, 3]
132+
my_list.extend([4, 5])
133+
print(my_list) # Output: [1, 2, 3, 4, 5]
134+
```
135+
136+
## Explain the use of lambda functions in Python.
137+
138+
Lambda functions are anonymous functions used for short tasks. Example:
139+
140+
Defining and using a lambda function:
141+
142+
```
143+
square = lambda x: x**2
144+
print(square(5)) # Output: 25
145+
```
146+
147+
## What are the different types of loops in Python?
148+
149+
Python has for loops and while loops.
150+
151+
Example:
152+
153+
Using for loop:
154+
```
155+
for i in range(5):
156+
print(i)
157+
```
158+
159+
Using while loop:
160+
```
161+
i = 0
162+
while i < 5:
163+
print(i)
164+
i += 1
165+
```
166+
167+
## Explain the difference between == and is operators.
168+
169+
The == operator compares the values of two objects, while the is operator checks if two variables point to the same object in memory.
170+
171+
Example:
172+
173+
Using ==:
174+
175+
```
176+
a = [1, 2, 3]
177+
b = [1, 2, 3]
178+
print(a == b) # Output: True (because values are equal)
179+
```
180+
181+
Using is:
182+
183+
```
184+
a = [1, 2, 3]
185+
b = a
186+
print(a is b) # Output: True (because they reference the same object)
187+
```
188+
189+
## What is the use of the pass keyword?
190+
191+
The pass keyword is a no-operation placeholder used when a statement is syntactically needed but no action is required. Example:
192+
193+
Using pass:
194+
```
195+
def placeholder_function():
196+
pass # To be implemented later
197+
```
198+
199+
## What is the difference between global and local variables?
200+
201+
Global variables are defined outside functions and can be accessed anywhere in the code, while local variables are defined inside functions and are only accessible within that function's scope. Example:
202+
203+
Using a global variable:
204+
```
205+
global_var = 10
206+
207+
def my_function():
208+
print(global_var)
209+
210+
my_function() # Output: 10
211+
```
212+
213+
Using a local variable:
214+
215+
```
216+
def my_function():
217+
local_var = 5
218+
print(local_var)
219+
220+
my_function() # Output: 5
221+
# Attempting to access local_var outside the function will result in an error
222+
```
223+
224+
## Explain the difference between open() and with open() statement.
225+
226+
open() is a built-in function used to open a file and return a file object.
227+
However, it's crucial to manually close the file using file_object.close().
228+
Conversely, with open() is a context manager that automatically handles file closure, ensuring clean-up even if exceptions occur.
229+
230+
Example:
231+
```
232+
file = open('example.txt', 'r')
233+
content = file.read()
234+
file.close()
235+
```
236+
237+
Using with open():
238+
```
239+
with open('example.txt', 'r') as file:
240+
content = file.read()
241+
# File is automatically closed when the block exits
242+
```
243+
244+

README.md

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,45 +61,41 @@
6161
- Practice exercises and examples:
6262
- Example: Print list of files in the list of folders provided
6363

64-
## Day 11: Working with Dictionaries and Sets
64+
## Day 11: Working with Dictionaries and Sets (Project-1)
6565
- Dictionaries and key-value pairs.
6666
- Sets and set operations.
6767
- Practice exercises and examples:
6868
- Example: Managing a dictionary of server configurations and optimizing retrieval.
6969

70-
## Day 12: Python Tasks for DevOps (Part 1) - File Operations
70+
## Day 12: Python Tasks for DevOps (Part 1) - File Operations (Project-2)
7171
- Introduction to File Operations and Boto3.
7272
- Automating File operations.
7373
- Practice exercises and examples:
7474
- Example: Update a server resources in the server.conf file up on external notification.
7575

76-
## Day 13: Python Tasks for DevOps (Part 2)
76+
## Day 13: Python Tasks for DevOps (Part 2) (Project-3)
7777
- Using Fabric for remote task automation.
7878
- AWS automation with Boto3.
7979
- Managing EC2 instances, S3 buckets, and more.
8080
- Practice exercises and examples:
8181
- Example: Creating a aws script for deploying applications to remote servers.
8282

83-
## Day 14: Working with RESTful APIs
83+
## Day 14: Github-JIRA intergration Project - (Project-4)
8484
- Introduction to RESTful APIs.
8585
- Making HTTP requests using Python.
8686
- Parsing JSON responses and error handling.
8787
- Practice exercises and examples:
88-
- Example: Developing a script to monitor RESTful API endpoints for your DevOps tools.
88+
- Example: Write a Python API which listens on a github comment and creates a ticket in JIRA.
8989

90-
## Day 15: Data Serialization and Configuration Files
91-
- Serializing and deserializing data (JSON, YAML).
92-
- Managing configuration data.
93-
- DevOps use cases for configuration files.
90+
## Day 15: Github-JIRA intergration Project - (Project-4) - (Part-2)
91+
- Introduction to Flask.
92+
- Write your first API in python.
93+
- How to handle API calls and deploy your API to a server.
9494
- Practice exercises and examples:
95-
- Example: Building a configuration manager to handle application settings in JSON format.
95+
- Example: Write a Python API which listens on a github comment and creates a ticket in JIRA.
9696

97-
## Day 16: Automation with Cron Jobs
98-
- Scheduling automated tasks using cron.
99-
- Creating Python scripts for scheduled automation.
100-
- Handling periodic tasks and reports.
101-
- Practice exercises and examples:
102-
- Example: Using cron and Python to schedule regular backups of your data.
97+
## Day 16: Python Interview Questions & Answers
98+
- Beginner and intermediate Level
10399

104100
## Day 17: Python Interview Questions & Answers
105-
101+
- Advanced Level

0 commit comments

Comments
 (0)