Add a couple of questions and answers

This commit is contained in:
abregman 2021-02-17 21:58:58 +02:00
parent 874418fa74
commit fe3cf0d5db

112
README.md
View File

@ -2,7 +2,7 @@
:information_source:  This repo contains questions and exercises on various technical topics, sometimes related to DevOps and SRE :) :information_source:  This repo contains questions and exercises on various technical topics, sometimes related to DevOps and SRE :)
:bar_chart:  There are currently **1509** questions :bar_chart:  There are currently **1518** questions
:books:  To learn more about DevOps and SRE, check the resources in [devops-resources](https://github.com/bregman-arie/devops-resources) repository :books:  To learn more about DevOps and SRE, check the resources in [devops-resources](https://github.com/bregman-arie/devops-resources) repository
@ -428,6 +428,16 @@ This situation might lead to bugs which hard to identify and reproduce.
Configuration drift can be avoided with desired state configuration (DSC) implementation. Desired state configuration can be a declarative file that defined how a system should be. There are tools to enforce desired state such a terraform or azure dsc. There are incramental or complete strategies. Configuration drift can be avoided with desired state configuration (DSC) implementation. Desired state configuration can be a declarative file that defined how a system should be. There are tools to enforce desired state such a terraform or azure dsc. There are incramental or complete strategies.
</b></details> </b></details>
<details>
<summary>Explain Declarative and Procedural styles. Give examples for each style</summary><br><b>
Declarative - You can write code that specifies the desired end state
Procedural - You describe the steps to get to the desired end state
Declarative Tools - Terraform, Puppet, CloudFormation
Procedural Tools - Ansible, Chef
</b></details>
<details> <details>
<summary>Do you have experience with testing cross-projects changes? (aka cross-dependency)</summary><br><b> <summary>Do you have experience with testing cross-projects changes? (aka cross-dependency)</summary><br><b>
@ -3951,12 +3961,23 @@ Ansible is:
* Focus on simpleness and ease-of-use * Focus on simpleness and ease-of-use
</b></details> </b></details>
<details>
<summary>True or False? Ansible follows the mutable infrastructure paradigm</summary><br><b>
True.
</b></details>
<details>
<summary>True or False? Ansible uses declarative style to describe the expected end state</summary><br><b>
False. It uses a procedural style.
</b></details>
<details> <details>
<summary>What kind of automation you wouldn't do with Ansible and why?</summary><br><b> <summary>What kind of automation you wouldn't do with Ansible and why?</summary><br><b>
While it's possible to provision resources with Ansible it might not be the best choice for doing so as Ansible doesn't While it's possible to provision resources with Ansible, some prefer to use tools that follow immutable infrastructure paradigm.
save state by default. So a task that creates 5 instances for example, when executed again will create additional 5 instances (unless Ansible doesn't saves state by default. So a task that creates 5 instances for example, when executed again will create additional 5 instances (unless
additional check is implemented). additional check is implemented) while other tools will check if 5 instances exist. If only 4 exist, additional instance will be created.
</b></details> </b></details>
<details> <details>
@ -4340,6 +4361,17 @@ The benefits of Terraform over the other tools:
* Ansible and Puppet are more procedural (you mention what to execute in each step) and Terraform is declarative since you describe the overall desired state and not per resource or task. You can give the example of going from 1 to 2 servers in each tool. In Terraform you specify 2, in Ansible and puppet you have to only provision 1 additional server so you need to explicitly make sure you provision only another one server. * Ansible and Puppet are more procedural (you mention what to execute in each step) and Terraform is declarative since you describe the overall desired state and not per resource or task. You can give the example of going from 1 to 2 servers in each tool. In Terraform you specify 2, in Ansible and puppet you have to only provision 1 additional server so you need to explicitly make sure you provision only another one server.
</b></details> </b></details>
<details>
<summary>True or False? Terraform follows the mutable infrastructure paradigm</summary><br><b>
False. Terraform follows immutable infrastructure paradigm.
</b></details>
<details>
<summary>True or False? Terraform uses declarative style to describe the expected end state</summary><br><b>
True
</b></details>
<details> <details>
<summary>Explain what is "Terraform configuration"</summary><br><b> <summary>Explain what is "Terraform configuration"</summary><br><b>
A configuration is a root module along with a tree of child modules that are called as dependencies from the root module. A configuration is a root module along with a tree of child modules that are called as dependencies from the root module.
@ -6010,6 +6042,10 @@ True
<summary>What is "Duck Typing"?</summary><br><b> <summary>What is "Duck Typing"?</summary><br><b>
</b></details> </b></details>
<details>
<summary>What is "Duck Typing"?</summary><br><b>
</b></details>
##### Common algorithms ##### Common algorithms
<details> <details>
@ -6081,6 +6117,15 @@ The average performance of the above algorithm is O(log n). Best performance can
<summary>Implement Stack in any language you would like</summary><br><b> <summary>Implement Stack in any language you would like</summary><br><b>
</b></details> </b></details>
<details>
<summary>Tell me everything you know about Linked Lists</summary><br><b>
* A linked list is a data structure
* It consists of a collection of nodes. Together these nodes represent a sequence
* Useful for use cases where you need to insert or remove an element from any position of the linked list
* Some programming languages don't have linked lists as a built-in data type (like Python for example) but it can be easily implemented
</b></details>
<details> <details>
<summary>Implement Hash table in any language you would like</summary><br><b> <summary>Implement Hash table in any language you would like</summary><br><b>
</b></details> </b></details>
@ -6163,6 +6208,18 @@ The immutable data types are:
Frozenset Frozenset
</b></details> </b></details>
<details>
<summary>What is a tuple in Python? What is it used for?</summary><br><b>
A tuple is a built-in data type in Python. It's used for storing multiple items in a single variable.
</b></details>
<details>
<summary>List, like a tuple, is also used for storing multiple items. What is then, the difference between a tuple and a list?</summary><br><b>
List, as opposed to a tuple, is a mutable data type. It means we can modify it and at items to it.
</b></details>
<details> <details>
<summary>What is the result of each of the following? <summary>What is the result of each of the following?
@ -7271,6 +7328,45 @@ What would be the result of is_int(2) and is_int(False)?
#### Python Data Structures & Types #### Python Data Structures & Types
<details>
<summary>Can you implement linked list in Python?</summary><br><b>
The reason we need to implement in the first place, it's because a linked list isn't part of Python standard library.<br>
To implement a linked list, we have to implement two concepts: The linked list itself and a node which is used by the linked list.
Let's start with a node. A node has some value and it also points to the next node
```
class Node(object):
def __init__(self, data):
self.data = data
self.next = None
```
Now the linked list. An empty linked list has nothing but an empty head.
```
class LinkedList(object):
def __init__(self):
self.head = None
```
Now we can start using the linked list
```
ll = Linkedlist()
ll.head = Node(1)
ll.head.next = Node(2)
ll.head.next.next = Node(3)
```
What we have is:
---- ----- ----
| 1 | -> | 2 | -> | 3 |
---- ----- -----
</b></details>
<details> <details>
<summary>Implement Stack in Python</summary><br><b> <summary>Implement Stack in Python</summary><br><b>
</b></details> </b></details>
@ -7627,10 +7723,6 @@ a = f()
<summary>Do you have experience with web scraping? Can you describe what have you used and for what?</summary><br><b> <summary>Do you have experience with web scraping? Can you describe what have you used and for what?</summary><br><b>
</b></details> </b></details>
<details>
<summary>Can you implement Linked List in Python?</summary><br><b>
</b></details>
<details> <details>
<summary>Can you implement Linux's <code>tail</code> command in Python? Bonus: implement <code>head</code> as well</summary><br><b> <summary>Can you implement Linux's <code>tail</code> command in Python? Bonus: implement <code>head</code> as well</summary><br><b>
</b></details> </b></details>
@ -10993,9 +11085,9 @@ Bonus: extract the last word of each line
<summary>Replace 'red' with 'green'</summary><br><b> <summary>Replace 'red' with 'green'</summary><br><b>
</b></details> </b></details>
## System Design ## System Designotebookn
This section contains only questions on System Design subject. The exercises can be found in [system-design-exercises repository](https://github.com/bregman-arie/system-design-exercises). This section contains only questions on System Design subject. The exercises can be found in [system-design-notebook repository](https://github.com/bregman-arie/system-design-notebook).
#### Architecture #### Architecture