From fe3cf0d5db999f9a46809ca91b36a1e13cd8d9e2 Mon Sep 17 00:00:00 2001 From: abregman Date: Wed, 17 Feb 2021 21:58:58 +0200 Subject: [PATCH] Add a couple of questions and answers --- README.md | 112 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 102 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index e7da452..8e7f502 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ :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 @@ -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. +
+Explain Declarative and Procedural styles. Give examples for each style
+ +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 +
+
Do you have experience with testing cross-projects changes? (aka cross-dependency)
@@ -3951,12 +3961,23 @@ Ansible is: * Focus on simpleness and ease-of-use
+
+True or False? Ansible follows the mutable infrastructure paradigm
+ +True. +
+ +
+True or False? Ansible uses declarative style to describe the expected end state
+False. It uses a procedural style. +
+
What kind of automation you wouldn't do with Ansible and why?
-While it's possible to provision resources with Ansible it might not be the best choice for doing so as Ansible doesn't -save 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). +While it's possible to provision resources with Ansible, some prefer to use tools that follow immutable infrastructure paradigm. +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) while other tools will check if 5 instances exist. If only 4 exist, additional instance will be created.
@@ -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.
+
+True or False? Terraform follows the mutable infrastructure paradigm
+ +False. Terraform follows immutable infrastructure paradigm. +
+ +
+True or False? Terraform uses declarative style to describe the expected end state
+True +
+
Explain what is "Terraform configuration"
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 What is "Duck Typing"?
+
+What is "Duck Typing"?
+
+ ##### Common algorithms
@@ -6081,6 +6117,15 @@ The average performance of the above algorithm is O(log n). Best performance can Implement Stack in any language you would like
+
+Tell me everything you know about Linked Lists
+ + * 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 +
+
Implement Hash table in any language you would like
@@ -6163,6 +6208,18 @@ The immutable data types are: Frozenset
+
+What is a tuple in Python? What is it used for?
+ +A tuple is a built-in data type in Python. It's used for storing multiple items in a single variable. +
+ +
+List, like a tuple, is also used for storing multiple items. What is then, the difference between a tuple and a list?
+ +List, as opposed to a tuple, is a mutable data type. It means we can modify it and at items to it. +
+
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 +
+Can you implement linked list in Python?
+ +The reason we need to implement in the first place, it's because a linked list isn't part of Python standard library.
+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 | +---- ----- ----- +
+
Implement Stack in Python
@@ -7627,10 +7723,6 @@ a = f() Do you have experience with web scraping? Can you describe what have you used and for what?
-
-Can you implement Linked List in Python?
-
-
Can you implement Linux's tail command in Python? Bonus: implement head as well
@@ -10993,9 +11085,9 @@ Bonus: extract the last word of each line Replace 'red' with 'green'
-## 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