diff --git a/README.md b/README.md index c17bbb7..b2ea861 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ :information_source:  This repository contains questions on various DevOps and SRE related topics -:bar_chart:  There are currently **720** questions +:bar_chart:  There are currently **725** questions :books:  To learn more about DevOps check the resources in [DevOpsBit.com](https://devopsbit.com) @@ -2509,6 +2509,14 @@ Setting the replicas to 0 will shut down the process. Now start it with `kubectl What programming language do you prefer to use for DevOps related tasks? Why specifically this one?
+
+Explain expressions and statements
+ +An expression is anything that results in a value (even if the value is None). Basically, any sequence of literals so, you can say that a string, integer, list, ... are all expressions. + +Statements are instructions executed by the interpreter like variable assignments, for loops and conditionals (if-else). +
+
What is Object Oriented Programming? Why is it important?
@@ -2686,10 +2694,6 @@ def my_function(): You can then assign a function to a variables like this `x = my_function` or you can return functions as return values like this `return my_function` -
-Explain expressions and statements
-
-
What is PEP8? Give an example of 3 style guidelines
@@ -2704,6 +2708,13 @@ PEP8 is a list of coding conventions and style guidelines for Python 5. Use 4 spaces per indentation level
+
+What is the result of running [] is not []? explain the result
+ +It evaluates to True.
+The reason is that the two created empty list are different objects. `x is y` only evaluates to true when x and y are the same object. +
+
Explain inheritance and how to use it in Python
@@ -2768,16 +2779,13 @@ bruno.bark() Calling super() calls the Base method, thus, calling super().__init__() we called the Animal __init__. There is a more advanced python feature called MetaClasses that aid the programmer to directly control class creation. - ``` -
What is an error? What is an exception? What types of exceptions are you familiar with?
``` - # Note that you generally don't need to know the compiling process but knowing where everything comes from # and giving complete answers shows that you truly know what you are talking about. @@ -2834,10 +2842,7 @@ Generally, every compiling process have a two steps. division(100, 2) >>> __main__.DividedBy2Error: I dont want you to divide by 2! - ``` - -
@@ -2845,7 +2850,11 @@ Generally, every compiling process have a two steps.
-Explain Exception Handling and how to use it in Python
+What _ is used for in Python?
+ +1. Translation lookup in i18n +2. Hold the result of the last executed expression or statement in the interactive interpreter. +3. As a general purpose "throwaway" variable name. For example: x, y, _ = get_data() (x and y are used but since we don't care about third variable, we "threw it away").
@@ -2861,11 +2870,10 @@ Generally, every compiling process have a two steps.
-How to extract the unique characters from a string? for example given the input "itssssssameeeemarioooooo" the output will be "mrtisaoe"
+How do you swap values between two variables?
``` -x = "itssssssameeeemarioooooo" -y = ''.join(set(x)) +x, y = y, x ```
@@ -2887,23 +2895,12 @@ def return_sum(): ``` +#### Lists +
How to merge two sorted lists into one sorted list?
-
-How to merge two dictionaries?
-
- -
-How do you swap values between two variables?
- -``` -x, y = y, x -``` - -
-
How to check if all the elements in a given lists are unique? so [1, 2, 3] is unique but [1, 1, 2, 3] is not unique because 1 exists twice
@@ -2947,23 +2944,37 @@ This one might look more convulated but hey, one liners. def is_unique4(l:list) -> bool: return all(map(lambda x: l.count(x) < 2, l)) ``` -
-What _ is used for in Python?
+You have the following function -1. Translation lookup in i18n -2. Hold the result of the last executed expression or statement in the interactive interpreter. -3. As a general purpose "throwaway" variable name. For example: x, y, _ = get_data() (x and y are used but since we don't care about third variable, we "threw it away"). +``` +def my_func(li = []): + li.append("hmm") + print(li) +``` + +If we call it 3 times, what would be the result each call? +
-How to check how much time it took to execute a certain script or block of code?
+How to iterate over a list in reverse order?
+
+ +#### Dictionaries + +
+How to sort a dictionary by values?
-Find all the permutations of a given string
+How to sort a dictionary by keys?
+
+ +
+How to merge two dictionaries?
##### Common Algorithms Implementation @@ -3050,7 +3061,28 @@ set([food for bro in x for food in bro['food']]) What is List Comprehension? Is it better than a typical loop? Why? Can you demonstrate how to use it?
-#### Practical +#### Strings + +
+How to extract the unique characters from a string? for example given the input "itssssssameeeemarioooooo" the output will be "mrtisaoe"
+ +``` +x = "itssssssameeeemarioooooo" +y = ''.join(set(x)) +``` +
+ +
+Find all the permutations of a given string
+
+ +
+How to check if a string contains a sub string?
+
+ +
+Find the frequency of each character in string
+
How to reverse a string? (e.g. pizza -> azzip)
@@ -3073,14 +3105,6 @@ def reverse_string(string): ```
-
-How to sort a dictionary by values?
-
- -
-How to sort a dictionary by keys?
-
-
Explain data serialization and how do you perform it with Python
@@ -3128,12 +3152,18 @@ the_list.sort(key=lambda x: x[1]) * filter()
+#### Debugging +
How do you debug Python code?
pdb :D
+
+How to check how much time it took to execute a certain script or block of code?
+
+
What empty return returns?
@@ -3207,19 +3237,6 @@ for i in range(1,10):
-
-You have the following function - -``` -def my_func(li = []): - li.append("hmm") - print(li) -``` - -If we call it 3 times, what would be the result each call? -
-
-
Given the following function @@ -3692,9 +3709,22 @@ You can use it for example to control endlines in files. In Windows and Unix bas
-How do you discard local file changes?
+How do you discard local file changes? (before commit)
-You can use `git checkout -- ` +`git checkout -- ` +
+ +
+How do you discard local commits?
+ +`git reset HEAD~1` for removing last commit +If you would like to also discard the changes you `git reset --hard`` +
+ +
+True or False? To remove a file from git but not from the filesystem, one should use git rm
+ +False. If you would like to keep a file on your filesystem, use `git reset `