From f85dacd8cac34e2010fc12a7971461ca62e5b268 Mon Sep 17 00:00:00 2001
From: Osama-Rashid <40798025+Osama-Rashid@users.noreply.github.com>
Date: Wed, 24 Nov 2021 10:39:14 +0500
Subject: [PATCH 1/3] Added the github workflow for CI (#190)
* Added the CI workflow which runs the scripts under the scripts/ folder
* testing ci workflow
* Gave required permission to the CI script
* Removed a typo
* Added shell parameter to job step in the workflow
* Added the sh command to run the script
* Added the command to install flake8 for running the ci workflow
* Corrected a typo
---
.github/workflows/ci_workflow.yml | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
create mode 100644 .github/workflows/ci_workflow.yml
diff --git a/.github/workflows/ci_workflow.yml b/.github/workflows/ci_workflow.yml
new file mode 100644
index 0000000..1cac7b1
--- /dev/null
+++ b/.github/workflows/ci_workflow.yml
@@ -0,0 +1,24 @@
+name: CI
+
+on:
+ # Triggers the workflow on pull request events for the main and devel branch
+ pull_request:
+ branches: [ main, devel ]
+
+ # Allows running this workflow manually from the Actions tab
+ workflow_dispatch:
+
+jobs:
+ # Contains a single job called "ci"
+ ci:
+ runs-on: ubuntu-latest
+ steps:
+ # Checks out repository under $GITHUB_WORKSPACE, so job can access it
+ - uses: actions/checkout@v2
+ - name: Install flake8
+ run: sudo apt install flake8
+ - name: Give executable permissions to the script
+ run: chmod a+x scripts/run_ci.sh
+ - name: Run the ci script in scripts folder
+ run: sh scripts/run_ci.sh
+ shell: bash
From a2db75ed523e8f90fe288c5a1c161e4d38ce7951 Mon Sep 17 00:00:00 2001
From: Adrian <59370927+adrianfusco@users.noreply.github.com>
Date: Wed, 24 Nov 2021 20:12:25 +0100
Subject: [PATCH 2/3] Feature/new python answers (#191)
* New questions and spell check (#181)
Added new questions related with KVM, Libvirt and DNF
* New answers
* Adding a note about which way is faster: Union vs Bitwise
* Add comment about slicing vs reversed
---
README.md | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 95 insertions(+)
diff --git a/README.md b/README.md
index abae334..29e5e79 100644
--- a/README.md
+++ b/README.md
@@ -3033,8 +3033,38 @@ You can then assign a function to a variables like this `x = my_function` or you
Write a function to determine if a number is a Palindrome
+- Code:
+
```
+from typing import Union
+
+def isNumberPalindrome(number: Union[int, str]) -> bool:
+ if isinstance(number, int):
+ number = str(number)
+ return number == number[::-1]
+
+print(isNumberPalindrome("12321"))
```
+
+- Using Python3.10 that accepts using bitwise operator '|'.
+
+```
+def isNumberPalindrome(number: int | str) -> bool:
+ if isinstance(number, int):
+ number = str(number)
+ return number == number[::-1]
+
+print(isNumberPalindrome("12321"))
+```
+
+Note: Using slicing to reverse a list could be slower than other options like `reversed` that return an iterator.
+
+- Result:
+
+```
+True
+```
+
#### Python - OOP
@@ -3241,6 +3271,28 @@ False
What is the __call__ method?
+
+It is used to emulate callable objects. It allows a class instance to be called as a function.
+
+- Example code:
+
+```
+class Foo:
+ def __init__(self: object) -> None:
+ pass
+ def __call__(self: object) -> None:
+ print("Called!")
+
+f = Foo()
+f()
+```
+
+- Result:
+
+```
+Called!
+```
+
@@ -3427,6 +3479,24 @@ some_list[:3]
How to insert an item to the beginning of a list? What about two items?
+
+- One item:
+
+```
+numbers = [1, 2, 3, 4, 5]
+numbers.insert(0, 0)
+print(numbers)
+```
+
+- Multiple items or list:
+
+```
+numbers_1 = [2, 3, 4, 5]
+numbers_2 = [0, 1]
+numbers_1 = numbers_2 + numbers_1
+print(numbers_1)
+```
+
@@ -3634,6 +3704,31 @@ list(zip(nums, letters))
What is List Comprehension? Is it better than a typical loop? Why? Can you demonstrate how to use it?
+
+From [Docs](https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions): "List comprehensions provide a concise way to create lists. Common applications are to make new lists where each element is the result of some operations applied to each member of another sequence or iterable, or to create a subsequence of those elements that satisfy a certain condition.".
+
+It's better because they're compact, faster and have better readability.
+
+- For loop:
+
+```
+number_lists = [[1, 7, 3, 1], [13, 93, 23, 12], [123, 423, 456, 653, 124]]
+odd_numbers = []
+for number_list in number_lists:
+ for number in number_list:
+ if number % 2 == 0:
+ odd_numbers.append(number)
+print(odd_numbers)
+```
+
+- List comprehesion:
+
+```
+number_lists = [[1, 7, 3, 1], [13, 93, 23, 12], [123, 423, 456, 653, 124]]
+odd_numbers = [number for number_list in number_lists for number in number_list if number % 2 == 0]
+print(odd_numbers)
+```
+
From 023cf57f906afadb0ab490b2616b1fb6564126ae Mon Sep 17 00:00:00 2001
From: Abiel7 <56592834+Abiel7@users.noreply.github.com>
Date: Thu, 25 Nov 2021 10:15:13 +0100
Subject: [PATCH 3/3] update (#192)
updated much to must
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 29e5e79..373247a 100644
--- a/README.md
+++ b/README.md
@@ -7664,7 +7664,7 @@ Not only this will tell you what is expected from you, it will also provide big
What does it mean when a database is ACID compliant?
-ACID stands for Atomicity, Consistency, Isolation, Durability. In order to be ACID compliant, the database much meet each of the four criteria
+ACID stands for Atomicity, Consistency, Isolation, Durability. In order to be ACID compliant, the database must meet each of the four criteria
**Atomicity** - When a change occurs to the database, it should either succeed or fail as a whole.