From db7b0f0024f1031c26c25d3d1d266832ae640e42 Mon Sep 17 00:00:00 2001 From: Boshra Mahmoudi Date: Tue, 28 Jul 2026 02:16:00 +0100 Subject: [PATCH 01/23] ls exercises --- individual-shell-tools/ls/script-01.sh | 2 ++ individual-shell-tools/ls/script-02.sh | 2 ++ individual-shell-tools/ls/script-03.sh | 2 ++ individual-shell-tools/ls/script-04.sh | 4 ++++ 4 files changed, 10 insertions(+) diff --git a/individual-shell-tools/ls/script-01.sh b/individual-shell-tools/ls/script-01.sh index 241b62f5e..8f93bb79e 100755 --- a/individual-shell-tools/ls/script-01.sh +++ b/individual-shell-tools/ls/script-01.sh @@ -13,3 +13,5 @@ fi # TODO: Write a command to list the files and folders in this directory. # The output should be a list of names including child-directory, script-01.sh, script-02.sh, and more. + +ls \ No newline at end of file diff --git a/individual-shell-tools/ls/script-02.sh b/individual-shell-tools/ls/script-02.sh index d0a5a10f4..b026cfd6c 100755 --- a/individual-shell-tools/ls/script-02.sh +++ b/individual-shell-tools/ls/script-02.sh @@ -4,3 +4,5 @@ set -euo pipefail # TODO: Write a command which lists all of the files in the directory named child-directory. # The output should be a list of names: helper-1.txt, helper-2.txt, helper-3.txt. + +ls child-directory diff --git a/individual-shell-tools/ls/script-03.sh b/individual-shell-tools/ls/script-03.sh index 781216d21..b259fcb1d 100755 --- a/individual-shell-tools/ls/script-03.sh +++ b/individual-shell-tools/ls/script-03.sh @@ -5,3 +5,5 @@ set -euo pipefail # TODO: Write a command which _recursively_ lists all of the files and folders in this directory _and_ all of the files inside those folders. # The output should be a list of names including: child-directory, script-01.sh, helper-1.txt (and more). # The formatting of the output doesn't matter. + +ls -R \ No newline at end of file diff --git a/individual-shell-tools/ls/script-04.sh b/individual-shell-tools/ls/script-04.sh index 72f3817b3..061b4f3d0 100755 --- a/individual-shell-tools/ls/script-04.sh +++ b/individual-shell-tools/ls/script-04.sh @@ -16,8 +16,12 @@ echo "First exercise (sorted newest to oldest):" # TODO: Write a command which lists the files in the child-directory directory, one per line, sorted so that the most recently modified file is first. # The output should be a list of names in this order, one per line: helper-3.txt, helper-1.txt, helper-2.txt. +ls -1t child-directory + echo "Second exercise (sorted oldest to newest):" # TODO: Write a command which does the same as above, but sorted in the opposite order (oldest first). # The output should be a list of names in this order, one per line: helper-2.txt, helper-1.txt, helper-3.txt. + +ls -1tr child-directory \ No newline at end of file From 721d271cef0dcb94eeb52a5cf23605e3c2eea8b8 Mon Sep 17 00:00:00 2001 From: Boshra Mahmoudi Date: Tue, 28 Jul 2026 02:29:00 +0100 Subject: [PATCH 02/23] cat exercise --- individual-shell-tools/cat/script-01.sh | 2 ++ individual-shell-tools/cat/script-02.sh | 2 ++ individual-shell-tools/cat/script-03.sh | 2 ++ individual-shell-tools/cat/script-04-stretch.sh | 2 ++ 4 files changed, 8 insertions(+) diff --git a/individual-shell-tools/cat/script-01.sh b/individual-shell-tools/cat/script-01.sh index c85053e0f..da5ec5029 100755 --- a/individual-shell-tools/cat/script-01.sh +++ b/individual-shell-tools/cat/script-01.sh @@ -4,3 +4,5 @@ set -euo pipefail # TODO: Write a command to output the contents of the helper-1.txt file inside the helper-files directory to the terminal. # The output of this command should be "Once upon a time...". + +cat ../helper-files/helper-1.txt \ No newline at end of file diff --git a/individual-shell-tools/cat/script-02.sh b/individual-shell-tools/cat/script-02.sh index 01bbd5eab..f645a1aff 100755 --- a/individual-shell-tools/cat/script-02.sh +++ b/individual-shell-tools/cat/script-02.sh @@ -11,3 +11,5 @@ set -euo pipefail # It looked delicious. # I was tempted to take a bite of it. # But this seemed like a bad idea... + +cat ../helper-files/*.txt \ No newline at end of file diff --git a/individual-shell-tools/cat/script-03.sh b/individual-shell-tools/cat/script-03.sh index 37573b0c1..e4e7c7fe3 100755 --- a/individual-shell-tools/cat/script-03.sh +++ b/individual-shell-tools/cat/script-03.sh @@ -9,3 +9,5 @@ set -euo pipefail # 1 It looked delicious. # 2 I was tempted to take a bite of it. # 3 But this seemed like a bad idea... + +cat -n ../helper-files/helper-3.txt \ No newline at end of file diff --git a/individual-shell-tools/cat/script-04-stretch.sh b/individual-shell-tools/cat/script-04-stretch.sh index 00fe3c48b..9ba3dfeb2 100755 --- a/individual-shell-tools/cat/script-04-stretch.sh +++ b/individual-shell-tools/cat/script-04-stretch.sh @@ -13,3 +13,5 @@ set -euo pipefail # 3 It looked delicious. # 4 I was tempted to take a bite of it. # 5 But this seemed like a bad idea... + +cat ../helper-files/*.txt | cat -n \ No newline at end of file From e4bcf76693cee50d9858a66cf210e5830dcee92a Mon Sep 17 00:00:00 2001 From: Boshra Mahmoudi Date: Tue, 28 Jul 2026 02:32:49 +0100 Subject: [PATCH 03/23] wc exercise --- individual-shell-tools/wc/script-01.sh | 2 ++ individual-shell-tools/wc/script-02.sh | 2 ++ individual-shell-tools/wc/script-03.sh | 2 ++ 3 files changed, 6 insertions(+) diff --git a/individual-shell-tools/wc/script-01.sh b/individual-shell-tools/wc/script-01.sh index c9dd6e5df..554bc7208 100755 --- a/individual-shell-tools/wc/script-01.sh +++ b/individual-shell-tools/wc/script-01.sh @@ -4,3 +4,5 @@ set -euo pipefail # TODO: Write a command to output the number of words in the file helper-files/helper-3.txt. # The output should include the number 19. The output should not include the number 92. + +wc % wc -w ../helper-files/helper-3.txt \ No newline at end of file diff --git a/individual-shell-tools/wc/script-02.sh b/individual-shell-tools/wc/script-02.sh index 8feeb1a62..ae2ae870b 100755 --- a/individual-shell-tools/wc/script-02.sh +++ b/individual-shell-tools/wc/script-02.sh @@ -4,3 +4,5 @@ set -euo pipefail # TODO: Write a command to output the number of lines in the file helper-files/helper-3.txt. # The output should include the number 3. The output should not include the number 19. + +wc -l ../helper-files/helper-3.txt diff --git a/individual-shell-tools/wc/script-03.sh b/individual-shell-tools/wc/script-03.sh index 6b2e9d3d1..3bc287a1a 100755 --- a/individual-shell-tools/wc/script-03.sh +++ b/individual-shell-tools/wc/script-03.sh @@ -8,3 +8,5 @@ set -euo pipefail # 1 7 39 ../helper-files/helper-2.txt # 3 19 92 ../helper-files/helper-3.txt # 5 30 151 total + +wc ../helper-files/*.txt \ No newline at end of file From c48dcce2b8f101b64f94f767111e84b4744c5cec Mon Sep 17 00:00:00 2001 From: Boshra Mahmoudi Date: Tue, 28 Jul 2026 02:47:11 +0100 Subject: [PATCH 04/23] grep exercise --- individual-shell-tools/grep/script-01.sh | 2 ++ individual-shell-tools/grep/script-02.sh | 2 ++ individual-shell-tools/grep/script-03.sh | 2 ++ individual-shell-tools/grep/script-04.sh | 2 ++ individual-shell-tools/grep/script-05.sh | 2 ++ individual-shell-tools/grep/script-06.sh | 2 ++ individual-shell-tools/grep/script-07.sh | 2 ++ 7 files changed, 14 insertions(+) diff --git a/individual-shell-tools/grep/script-01.sh b/individual-shell-tools/grep/script-01.sh index fb05f42f2..acf8b4a96 100755 --- a/individual-shell-tools/grep/script-01.sh +++ b/individual-shell-tools/grep/script-01.sh @@ -4,3 +4,5 @@ set -euo pipefail # TODO: Write a command to output every line in dialogue.txt said by the Doctor. # The output should contain 6 lines. + +grep ^Doctor: dialogue.txt \ No newline at end of file diff --git a/individual-shell-tools/grep/script-02.sh b/individual-shell-tools/grep/script-02.sh index df6f85640..e05ea7ca6 100755 --- a/individual-shell-tools/grep/script-02.sh +++ b/individual-shell-tools/grep/script-02.sh @@ -4,3 +4,5 @@ set -euo pipefail # TODO: Write a command to output every line in dialogue.txt that contains the word Doctor (regardless of case). # The output should contain 9 lines. + +grep -i Doctor dialogue.txt \ No newline at end of file diff --git a/individual-shell-tools/grep/script-03.sh b/individual-shell-tools/grep/script-03.sh index 5383fe578..a6fef46f2 100755 --- a/individual-shell-tools/grep/script-03.sh +++ b/individual-shell-tools/grep/script-03.sh @@ -4,3 +4,5 @@ set -euo pipefail # TODO: Write a command to output the number of lines in dialogue.txt that contain the word Doctor (regardless of case). # The output should be exactly the number 9. + +grep -ic Doctor dialogue.txt \ No newline at end of file diff --git a/individual-shell-tools/grep/script-04.sh b/individual-shell-tools/grep/script-04.sh index 80ee04776..24bb2dfd7 100755 --- a/individual-shell-tools/grep/script-04.sh +++ b/individual-shell-tools/grep/script-04.sh @@ -4,3 +4,5 @@ set -euo pipefail # TODO: Write a command to output every line in dialogue.txt that does not contain the word "Hello" (regardless of case). # The output should contain 10 lines. + +grep -iv Hello dialogue.txt \ No newline at end of file diff --git a/individual-shell-tools/grep/script-05.sh b/individual-shell-tools/grep/script-05.sh index 1eb538185..2391a370e 100755 --- a/individual-shell-tools/grep/script-05.sh +++ b/individual-shell-tools/grep/script-05.sh @@ -4,3 +4,5 @@ set -euo pipefail # TODO: Write a command to output every line in dialogue.txt that contains the string "cure", as well as the line before that line. # The output should contain two pairs of two lines of text (with a separator between them). + +grep % grep -B 1 "cure" dialogue.txt \ No newline at end of file diff --git a/individual-shell-tools/grep/script-06.sh b/individual-shell-tools/grep/script-06.sh index 5670e3b6c..c5b842195 100755 --- a/individual-shell-tools/grep/script-06.sh +++ b/individual-shell-tools/grep/script-06.sh @@ -4,3 +4,5 @@ set -euo pipefail # TODO: Write a command to output the name of every `.txt` file in this directory which contains a line of dialogue said by the Doctor. # The output should contain two filenames. + +grep -l ^Doctor: *.txt \ No newline at end of file diff --git a/individual-shell-tools/grep/script-07.sh b/individual-shell-tools/grep/script-07.sh index 9670ebad9..2ebba084b 100755 --- a/individual-shell-tools/grep/script-07.sh +++ b/individual-shell-tools/grep/script-07.sh @@ -4,3 +4,5 @@ set -euo pipefail # TODO: Write a command to output, for each `.txt` file in this directory, how many lines of dialogue the Doctor has. # The output should show that dialogue.txt contains 6 lines, dialogue-2.txt contains 2, and dialogue-3.txt contains 0. + +grep -c ^Doctor: *.txt From 8157633bd0a997a9cf5856403a744176879c926f Mon Sep 17 00:00:00 2001 From: Boshra Mahmoudi Date: Tue, 28 Jul 2026 03:00:30 +0100 Subject: [PATCH 05/23] sed exercise --- individual-shell-tools/sed/script-01.sh | 2 ++ individual-shell-tools/sed/script-02.sh | 2 ++ individual-shell-tools/sed/script-03.sh | 2 ++ individual-shell-tools/sed/script-04.sh | 2 ++ individual-shell-tools/sed/script-05.sh | 2 ++ individual-shell-tools/sed/script-06.sh | 2 ++ 6 files changed, 12 insertions(+) diff --git a/individual-shell-tools/sed/script-01.sh b/individual-shell-tools/sed/script-01.sh index d592970fc..5d35f024c 100755 --- a/individual-shell-tools/sed/script-01.sh +++ b/individual-shell-tools/sed/script-01.sh @@ -5,3 +5,5 @@ set -euo pipefail # TODO: Write a command to output input.txt with all occurrences of the letter `i` replaced with `I`. # The output should contain 11 lines. # The first line of the output should be: "ThIs Is a sample fIle for experImentIng wIth sed.". + +sed % sed 's/i/I/' input.txt \ No newline at end of file diff --git a/individual-shell-tools/sed/script-02.sh b/individual-shell-tools/sed/script-02.sh index abdd64d06..0f32ffd6b 100755 --- a/individual-shell-tools/sed/script-02.sh +++ b/individual-shell-tools/sed/script-02.sh @@ -5,3 +5,5 @@ set -euo pipefail # TODO: Write a command to output input.txt with numbers removed. # The output should contain 11 lines. # Line 6 of the output should be " Alisha". + +sed 's/[0-9]*//g' input.txt \ No newline at end of file diff --git a/individual-shell-tools/sed/script-03.sh b/individual-shell-tools/sed/script-03.sh index dd284a296..e70f4a600 100755 --- a/individual-shell-tools/sed/script-03.sh +++ b/individual-shell-tools/sed/script-03.sh @@ -4,3 +4,5 @@ set -euo pipefail # TODO: Write a command to output input.txt removing any line which contains a number. # The output should contain 6 lines. + +sed '/[0-9]/d' input.txt diff --git a/individual-shell-tools/sed/script-04.sh b/individual-shell-tools/sed/script-04.sh index 0052ac6c4..8ac6e7c5d 100755 --- a/individual-shell-tools/sed/script-04.sh +++ b/individual-shell-tools/sed/script-04.sh @@ -4,3 +4,5 @@ set -euo pipefail # TODO: Write a command to output input.txt replacing every occurrence of the string "We'll" with "We will". # The output should contain 11 lines. + +sed "s/We'll/We will/g" input.txt diff --git a/individual-shell-tools/sed/script-05.sh b/individual-shell-tools/sed/script-05.sh index 2dcc91a0c..990ac2f2c 100755 --- a/individual-shell-tools/sed/script-05.sh +++ b/individual-shell-tools/sed/script-05.sh @@ -6,3 +6,5 @@ set -euo pipefail # If a line starts with a number and a space, make the line instead end with a space and the number. # So line 6 which currently reads "37 Alisha" should instead read "Alisha 37". # The output should contain 11 lines. + +sed -E 's/^([0-9]+) (.*)$/\2 \1/' input.txt diff --git a/individual-shell-tools/sed/script-06.sh b/individual-shell-tools/sed/script-06.sh index 0b9390170..6dad6a948 100755 --- a/individual-shell-tools/sed/script-06.sh +++ b/individual-shell-tools/sed/script-06.sh @@ -8,3 +8,5 @@ set -euo pipefail # The output should contain 11 lines. # Line 3 should be "It contains many lines, and there are some things you may want to do with each of them.". # Line 11 should be "We also should remember, when we go shopping, to get 4 items: oranges, cheese, bread, olives.". + +sed 's/^\([0-9][0-9]*\) \(.*\)$/\2 \1/' input.txt \ No newline at end of file From 0d520d4953b13d2b271a1ae02ed1a4d580d57021 Mon Sep 17 00:00:00 2001 From: Boshra Mahmoudi Date: Tue, 28 Jul 2026 03:14:09 +0100 Subject: [PATCH 06/23] awk exercise --- individual-shell-tools/awk/script-01.sh | 2 ++ individual-shell-tools/awk/script-02.sh | 2 ++ individual-shell-tools/awk/script-03.sh | 2 ++ individual-shell-tools/awk/script-04.sh | 2 ++ individual-shell-tools/awk/script-05.sh | 2 ++ 5 files changed, 10 insertions(+) diff --git a/individual-shell-tools/awk/script-01.sh b/individual-shell-tools/awk/script-01.sh index 8db4390af..587ed2acb 100755 --- a/individual-shell-tools/awk/script-01.sh +++ b/individual-shell-tools/awk/script-01.sh @@ -4,3 +4,5 @@ set -euo pipefail # TODO: Write a command to output just the names of each player in `scores-table.txt`. # Your output should contain 6 lines, each with just one word on it. + +awk '{print $1}' scores-table.txt \ No newline at end of file diff --git a/individual-shell-tools/awk/script-02.sh b/individual-shell-tools/awk/script-02.sh index 5956be9bd..a29bbbf1f 100755 --- a/individual-shell-tools/awk/script-02.sh +++ b/individual-shell-tools/awk/script-02.sh @@ -4,3 +4,5 @@ set -euo pipefail # TODO: Write a command to output the names of each player, as well as their city. # Your output should contain 6 lines, each with two words on it, separated by a space. + +awk '{print $1, $2}' scores-table.txt diff --git a/individual-shell-tools/awk/script-03.sh b/individual-shell-tools/awk/script-03.sh index af7c6e8b9..67365bfa4 100755 --- a/individual-shell-tools/awk/script-03.sh +++ b/individual-shell-tools/awk/script-03.sh @@ -5,3 +5,5 @@ set -euo pipefail # TODO: Write a command to output just the names of each player along with the score from their first attempt. # Your output should contain 6 lines, each with one word and one number on it. # The first line should be "Ahmed 1". + +awk '{print $1, $3}' scores-table.txt \ No newline at end of file diff --git a/individual-shell-tools/awk/script-04.sh b/individual-shell-tools/awk/script-04.sh index bf15703c7..6430de6dc 100755 --- a/individual-shell-tools/awk/script-04.sh +++ b/individual-shell-tools/awk/script-04.sh @@ -5,3 +5,5 @@ set -euo pipefail # TODO: Write a command to output just the names of each player in London along with the score from their last attempt. # Your output should contain 3 lines, each with one word and one number on it. # The first line should be "Ahmed 4". + +awk '$2 == "London" {print $1, $5}' scores-table.txt \ No newline at end of file diff --git a/individual-shell-tools/awk/script-05.sh b/individual-shell-tools/awk/script-05.sh index d1680cb02..0df43b872 100755 --- a/individual-shell-tools/awk/script-05.sh +++ b/individual-shell-tools/awk/script-05.sh @@ -5,3 +5,5 @@ set -euo pipefail # TODO: Write a command to output just the names of each player along with the number of times they've played the game. # Your output should contain 6 lines, each with one word and one number on it. # The first line should be "Ahmed 3". + +awk '{print $1, NF-2}' scores-table.txt \ No newline at end of file From 98447832a531c63f945217869fed99915a532b9a Mon Sep 17 00:00:00 2001 From: Boshra Mahmoudi Date: Tue, 28 Jul 2026 03:43:25 +0100 Subject: [PATCH 07/23] fix the errors --- individual-shell-tools/awk/script-04.sh | 2 +- individual-shell-tools/grep/script-05.sh | 2 +- individual-shell-tools/sed/script-01.sh | 2 +- individual-shell-tools/sed/script-06.sh | 2 +- individual-shell-tools/wc/script-01.sh | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/individual-shell-tools/awk/script-04.sh b/individual-shell-tools/awk/script-04.sh index 6430de6dc..79da3d066 100755 --- a/individual-shell-tools/awk/script-04.sh +++ b/individual-shell-tools/awk/script-04.sh @@ -6,4 +6,4 @@ set -euo pipefail # Your output should contain 3 lines, each with one word and one number on it. # The first line should be "Ahmed 4". -awk '$2 == "London" {print $1, $5}' scores-table.txt \ No newline at end of file +awk '$2 == "London" {print $1, $NF}' scores-table.txt \ No newline at end of file diff --git a/individual-shell-tools/grep/script-05.sh b/individual-shell-tools/grep/script-05.sh index 2391a370e..497a6e7f0 100755 --- a/individual-shell-tools/grep/script-05.sh +++ b/individual-shell-tools/grep/script-05.sh @@ -5,4 +5,4 @@ set -euo pipefail # TODO: Write a command to output every line in dialogue.txt that contains the string "cure", as well as the line before that line. # The output should contain two pairs of two lines of text (with a separator between them). -grep % grep -B 1 "cure" dialogue.txt \ No newline at end of file +grep -B 1 "cure" dialogue.txt \ No newline at end of file diff --git a/individual-shell-tools/sed/script-01.sh b/individual-shell-tools/sed/script-01.sh index 5d35f024c..a0b748a63 100755 --- a/individual-shell-tools/sed/script-01.sh +++ b/individual-shell-tools/sed/script-01.sh @@ -6,4 +6,4 @@ set -euo pipefail # The output should contain 11 lines. # The first line of the output should be: "ThIs Is a sample fIle for experImentIng wIth sed.". -sed % sed 's/i/I/' input.txt \ No newline at end of file +sed 's/i/I/' input.txt \ No newline at end of file diff --git a/individual-shell-tools/sed/script-06.sh b/individual-shell-tools/sed/script-06.sh index 6dad6a948..ab15800eb 100755 --- a/individual-shell-tools/sed/script-06.sh +++ b/individual-shell-tools/sed/script-06.sh @@ -9,4 +9,4 @@ set -euo pipefail # Line 3 should be "It contains many lines, and there are some things you may want to do with each of them.". # Line 11 should be "We also should remember, when we go shopping, to get 4 items: oranges, cheese, bread, olives.". -sed 's/^\([0-9][0-9]*\) \(.*\)$/\2 \1/' input.txt \ No newline at end of file +sed 's/, */, /g' input.txt \ No newline at end of file diff --git a/individual-shell-tools/wc/script-01.sh b/individual-shell-tools/wc/script-01.sh index 554bc7208..22b7b8d9e 100755 --- a/individual-shell-tools/wc/script-01.sh +++ b/individual-shell-tools/wc/script-01.sh @@ -5,4 +5,4 @@ set -euo pipefail # TODO: Write a command to output the number of words in the file helper-files/helper-3.txt. # The output should include the number 19. The output should not include the number 92. -wc % wc -w ../helper-files/helper-3.txt \ No newline at end of file +wc -w ../helper-files/helper-3.txt \ No newline at end of file From f8a25cc75d40159333beae39705590984f6d0284 Mon Sep 17 00:00:00 2001 From: Boshra Mahmoudi Date: Tue, 28 Jul 2026 10:42:06 +0100 Subject: [PATCH 08/23] fix: correct sed script-01 solution --- individual-shell-tools/sed/script-01.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/individual-shell-tools/sed/script-01.sh b/individual-shell-tools/sed/script-01.sh index a0b748a63..0bd78a317 100755 --- a/individual-shell-tools/sed/script-01.sh +++ b/individual-shell-tools/sed/script-01.sh @@ -6,4 +6,4 @@ set -euo pipefail # The output should contain 11 lines. # The first line of the output should be: "ThIs Is a sample fIle for experImentIng wIth sed.". -sed 's/i/I/' input.txt \ No newline at end of file +sed 's/i/I/g' input.txt \ No newline at end of file From 19015e584cb2da2107dec365e50583cf750cf274 Mon Sep 17 00:00:00 2001 From: Boshra Mahmoudi Date: Tue, 28 Jul 2026 11:41:27 +0100 Subject: [PATCH 09/23] part1 number systems --- number-systems/Part-1.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/number-systems/Part-1.md b/number-systems/Part-1.md index d8f9c290e..68b77ea0b 100644 --- a/number-systems/Part-1.md +++ b/number-systems/Part-1.md @@ -6,49 +6,49 @@ The goal of these exercises is for you to gain an intuition for binary numbers. The answers to these questions should be a number, either in binary, hex, or decimal. -Q1: Convert the decimal number 14 to binary. -Answer: +Q1: Convert the decimal number 14 to binary. 0,2,4,8,16,32,64,128,256 +Answer: 1110 Q2: Convert the binary number 101101 to decimal: -Answer: +Answer: 45 Q3: Which is larger: 1000 or 0111? -Answer: +Answer: 1000 Q4: Which is larger: 00100 or 01011? -Answer: +Answer: 01011 Q5: What is 10101 + 01010? -Answer: +Answer: 11111 Q6: What is 10001 + 10001? -Answer: +Answer: 100010 Q7: What's the largest number you can store with 4 bits, if you want to be able to represent the number 0? -Answer: +Answer: 15 Q8: How many bits would you need in order to store the numbers between 0 and 255 inclusive? -Answer: +Answer: 9 Q9: How many bits would you need in order to store the numbers between 0 and 3 inclusive? -Answer: +Answer: 2 Q10: How many bits would you need in order to store the numbers between 0 and 1000 inclusive? -Answer: +Answer: 10 Q11: Convert the decimal number 14 to hex. -Answer: +Answer: E Q12: Convert the decimal number 386 to hex. -Answer: +Answer: 182 Q13: Convert the hex number 386 to decimal. -Answer: +Answer: 902 Q14: Convert the hex number B to decimal. -Answer: +Answer: 11 Q15: If reading the byte 0x21 as a number, what decimal number would it mean? -Answer: +Answer: 33 Q16: Continues in Part-2 From 3e44d1cb6d008aa8376492a43e019440110283c5 Mon Sep 17 00:00:00 2001 From: Boshra Mahmoudi Date: Tue, 28 Jul 2026 12:27:55 +0100 Subject: [PATCH 10/23] part 2 number system --- number-systems/Part-2.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/number-systems/Part-2.md b/number-systems/Part-2.md index 68b0933d9..1fce42ee7 100644 --- a/number-systems/Part-2.md +++ b/number-systems/Part-2.md @@ -7,16 +7,18 @@ The goal of these exercises is for you to gain an intuition for binary numbers. The answers to these questions will require a bit of explanation, not just a simple answer. Q16: How can you test if a binary number is a power of two (e.g. 1, 2, 4, 8, 16, ...)? -Answer: +Answer: If there is just one 1 in a binary number, then it is a power of 2. This is because each bit represents a power of 2, so if there is just one 1 bit in a binary number, the value represents a power of 2. Q17: If reading the byte 0x21 as an ASCII character, what character would it mean? -Answer: +Answer: ! Q18: If reading the byte 0x21 as a greyscale colour, as described in "Approaches for Representing Colors and Images", what colour would it mean? -Answer: +Answer: It represents 33, which is in the range of 0–255 from dark to light. This value represents a very dark grey. Q19: If reading the bytes 0xAA00FF as a sequence of three one-byte decimal numbers, what decimal numbers would they be? -Answer: +Answer: three one-byte => +AA | 00 | FF ==> AA : 10 * 16 + 10 * 1 = 170 | 00 : 0 * 16 + 0 * 1 = 0 | FF : 15 * 16 + 15 * 1 = 255 +so it reperesnt 170, 0, 255 Q20: If reading the bytes 0xAA00FF as an RGB colour, as described in "Approaches for Representing Colors and Images", what colour would it mean? -Answer: +Answer: AA => 170 Red, 00 => 0 green , FF : 255 is blue From ad6bc8ea9952e0efad0607ee8f1d2335c08d52e5 Mon Sep 17 00:00:00 2001 From: Boshra Mahmoudi Date: Tue, 28 Jul 2026 13:05:36 +0100 Subject: [PATCH 11/23] updated branch --- individual-shell-tools/awk/script-01.sh | 2 -- individual-shell-tools/awk/script-02.sh | 2 -- individual-shell-tools/awk/script-03.sh | 2 -- individual-shell-tools/awk/script-04.sh | 2 -- individual-shell-tools/awk/script-05.sh | 2 -- individual-shell-tools/cat/script-01.sh | 2 -- individual-shell-tools/cat/script-02.sh | 2 -- individual-shell-tools/cat/script-03.sh | 2 -- individual-shell-tools/cat/script-04-stretch.sh | 2 -- individual-shell-tools/grep/script-01.sh | 2 -- individual-shell-tools/grep/script-02.sh | 2 -- individual-shell-tools/grep/script-03.sh | 2 -- individual-shell-tools/grep/script-04.sh | 2 -- individual-shell-tools/grep/script-05.sh | 2 -- individual-shell-tools/grep/script-06.sh | 2 -- individual-shell-tools/grep/script-07.sh | 2 -- individual-shell-tools/ls/script-01.sh | 3 +-- individual-shell-tools/ls/script-02.sh | 2 -- individual-shell-tools/ls/script-03.sh | 2 -- individual-shell-tools/ls/script-04.sh | 4 ---- individual-shell-tools/sed/script-01.sh | 2 -- individual-shell-tools/sed/script-02.sh | 2 -- individual-shell-tools/sed/script-03.sh | 2 -- individual-shell-tools/sed/script-04.sh | 2 -- individual-shell-tools/sed/script-05.sh | 2 -- individual-shell-tools/sed/script-06.sh | 2 -- individual-shell-tools/wc/script-01.sh | 2 -- individual-shell-tools/wc/script-02.sh | 2 -- individual-shell-tools/wc/script-03.sh | 2 -- 29 files changed, 1 insertion(+), 60 deletions(-) diff --git a/individual-shell-tools/awk/script-01.sh b/individual-shell-tools/awk/script-01.sh index 587ed2acb..8db4390af 100755 --- a/individual-shell-tools/awk/script-01.sh +++ b/individual-shell-tools/awk/script-01.sh @@ -4,5 +4,3 @@ set -euo pipefail # TODO: Write a command to output just the names of each player in `scores-table.txt`. # Your output should contain 6 lines, each with just one word on it. - -awk '{print $1}' scores-table.txt \ No newline at end of file diff --git a/individual-shell-tools/awk/script-02.sh b/individual-shell-tools/awk/script-02.sh index a29bbbf1f..5956be9bd 100755 --- a/individual-shell-tools/awk/script-02.sh +++ b/individual-shell-tools/awk/script-02.sh @@ -4,5 +4,3 @@ set -euo pipefail # TODO: Write a command to output the names of each player, as well as their city. # Your output should contain 6 lines, each with two words on it, separated by a space. - -awk '{print $1, $2}' scores-table.txt diff --git a/individual-shell-tools/awk/script-03.sh b/individual-shell-tools/awk/script-03.sh index 67365bfa4..af7c6e8b9 100755 --- a/individual-shell-tools/awk/script-03.sh +++ b/individual-shell-tools/awk/script-03.sh @@ -5,5 +5,3 @@ set -euo pipefail # TODO: Write a command to output just the names of each player along with the score from their first attempt. # Your output should contain 6 lines, each with one word and one number on it. # The first line should be "Ahmed 1". - -awk '{print $1, $3}' scores-table.txt \ No newline at end of file diff --git a/individual-shell-tools/awk/script-04.sh b/individual-shell-tools/awk/script-04.sh index 79da3d066..bf15703c7 100755 --- a/individual-shell-tools/awk/script-04.sh +++ b/individual-shell-tools/awk/script-04.sh @@ -5,5 +5,3 @@ set -euo pipefail # TODO: Write a command to output just the names of each player in London along with the score from their last attempt. # Your output should contain 3 lines, each with one word and one number on it. # The first line should be "Ahmed 4". - -awk '$2 == "London" {print $1, $NF}' scores-table.txt \ No newline at end of file diff --git a/individual-shell-tools/awk/script-05.sh b/individual-shell-tools/awk/script-05.sh index 0df43b872..d1680cb02 100755 --- a/individual-shell-tools/awk/script-05.sh +++ b/individual-shell-tools/awk/script-05.sh @@ -5,5 +5,3 @@ set -euo pipefail # TODO: Write a command to output just the names of each player along with the number of times they've played the game. # Your output should contain 6 lines, each with one word and one number on it. # The first line should be "Ahmed 3". - -awk '{print $1, NF-2}' scores-table.txt \ No newline at end of file diff --git a/individual-shell-tools/cat/script-01.sh b/individual-shell-tools/cat/script-01.sh index da5ec5029..c85053e0f 100755 --- a/individual-shell-tools/cat/script-01.sh +++ b/individual-shell-tools/cat/script-01.sh @@ -4,5 +4,3 @@ set -euo pipefail # TODO: Write a command to output the contents of the helper-1.txt file inside the helper-files directory to the terminal. # The output of this command should be "Once upon a time...". - -cat ../helper-files/helper-1.txt \ No newline at end of file diff --git a/individual-shell-tools/cat/script-02.sh b/individual-shell-tools/cat/script-02.sh index f645a1aff..01bbd5eab 100755 --- a/individual-shell-tools/cat/script-02.sh +++ b/individual-shell-tools/cat/script-02.sh @@ -11,5 +11,3 @@ set -euo pipefail # It looked delicious. # I was tempted to take a bite of it. # But this seemed like a bad idea... - -cat ../helper-files/*.txt \ No newline at end of file diff --git a/individual-shell-tools/cat/script-03.sh b/individual-shell-tools/cat/script-03.sh index e4e7c7fe3..37573b0c1 100755 --- a/individual-shell-tools/cat/script-03.sh +++ b/individual-shell-tools/cat/script-03.sh @@ -9,5 +9,3 @@ set -euo pipefail # 1 It looked delicious. # 2 I was tempted to take a bite of it. # 3 But this seemed like a bad idea... - -cat -n ../helper-files/helper-3.txt \ No newline at end of file diff --git a/individual-shell-tools/cat/script-04-stretch.sh b/individual-shell-tools/cat/script-04-stretch.sh index 9ba3dfeb2..00fe3c48b 100755 --- a/individual-shell-tools/cat/script-04-stretch.sh +++ b/individual-shell-tools/cat/script-04-stretch.sh @@ -13,5 +13,3 @@ set -euo pipefail # 3 It looked delicious. # 4 I was tempted to take a bite of it. # 5 But this seemed like a bad idea... - -cat ../helper-files/*.txt | cat -n \ No newline at end of file diff --git a/individual-shell-tools/grep/script-01.sh b/individual-shell-tools/grep/script-01.sh index acf8b4a96..fb05f42f2 100755 --- a/individual-shell-tools/grep/script-01.sh +++ b/individual-shell-tools/grep/script-01.sh @@ -4,5 +4,3 @@ set -euo pipefail # TODO: Write a command to output every line in dialogue.txt said by the Doctor. # The output should contain 6 lines. - -grep ^Doctor: dialogue.txt \ No newline at end of file diff --git a/individual-shell-tools/grep/script-02.sh b/individual-shell-tools/grep/script-02.sh index e05ea7ca6..df6f85640 100755 --- a/individual-shell-tools/grep/script-02.sh +++ b/individual-shell-tools/grep/script-02.sh @@ -4,5 +4,3 @@ set -euo pipefail # TODO: Write a command to output every line in dialogue.txt that contains the word Doctor (regardless of case). # The output should contain 9 lines. - -grep -i Doctor dialogue.txt \ No newline at end of file diff --git a/individual-shell-tools/grep/script-03.sh b/individual-shell-tools/grep/script-03.sh index a6fef46f2..5383fe578 100755 --- a/individual-shell-tools/grep/script-03.sh +++ b/individual-shell-tools/grep/script-03.sh @@ -4,5 +4,3 @@ set -euo pipefail # TODO: Write a command to output the number of lines in dialogue.txt that contain the word Doctor (regardless of case). # The output should be exactly the number 9. - -grep -ic Doctor dialogue.txt \ No newline at end of file diff --git a/individual-shell-tools/grep/script-04.sh b/individual-shell-tools/grep/script-04.sh index 24bb2dfd7..80ee04776 100755 --- a/individual-shell-tools/grep/script-04.sh +++ b/individual-shell-tools/grep/script-04.sh @@ -4,5 +4,3 @@ set -euo pipefail # TODO: Write a command to output every line in dialogue.txt that does not contain the word "Hello" (regardless of case). # The output should contain 10 lines. - -grep -iv Hello dialogue.txt \ No newline at end of file diff --git a/individual-shell-tools/grep/script-05.sh b/individual-shell-tools/grep/script-05.sh index 497a6e7f0..1eb538185 100755 --- a/individual-shell-tools/grep/script-05.sh +++ b/individual-shell-tools/grep/script-05.sh @@ -4,5 +4,3 @@ set -euo pipefail # TODO: Write a command to output every line in dialogue.txt that contains the string "cure", as well as the line before that line. # The output should contain two pairs of two lines of text (with a separator between them). - -grep -B 1 "cure" dialogue.txt \ No newline at end of file diff --git a/individual-shell-tools/grep/script-06.sh b/individual-shell-tools/grep/script-06.sh index c5b842195..5670e3b6c 100755 --- a/individual-shell-tools/grep/script-06.sh +++ b/individual-shell-tools/grep/script-06.sh @@ -4,5 +4,3 @@ set -euo pipefail # TODO: Write a command to output the name of every `.txt` file in this directory which contains a line of dialogue said by the Doctor. # The output should contain two filenames. - -grep -l ^Doctor: *.txt \ No newline at end of file diff --git a/individual-shell-tools/grep/script-07.sh b/individual-shell-tools/grep/script-07.sh index 2ebba084b..9670ebad9 100755 --- a/individual-shell-tools/grep/script-07.sh +++ b/individual-shell-tools/grep/script-07.sh @@ -4,5 +4,3 @@ set -euo pipefail # TODO: Write a command to output, for each `.txt` file in this directory, how many lines of dialogue the Doctor has. # The output should show that dialogue.txt contains 6 lines, dialogue-2.txt contains 2, and dialogue-3.txt contains 0. - -grep -c ^Doctor: *.txt diff --git a/individual-shell-tools/ls/script-01.sh b/individual-shell-tools/ls/script-01.sh index 8f93bb79e..754a44837 100755 --- a/individual-shell-tools/ls/script-01.sh +++ b/individual-shell-tools/ls/script-01.sh @@ -12,6 +12,5 @@ if [[ "${script_dir}" != "$(pwd)" ]]; then fi # TODO: Write a command to list the files and folders in this directory. -# The output should be a list of names including child-directory, script-01.sh, script-02.sh, and more. -ls \ No newline at end of file +# The output should be a list of names including child-directory, script-01.sh, script-02.sh, and more. \ No newline at end of file diff --git a/individual-shell-tools/ls/script-02.sh b/individual-shell-tools/ls/script-02.sh index b026cfd6c..d0a5a10f4 100755 --- a/individual-shell-tools/ls/script-02.sh +++ b/individual-shell-tools/ls/script-02.sh @@ -4,5 +4,3 @@ set -euo pipefail # TODO: Write a command which lists all of the files in the directory named child-directory. # The output should be a list of names: helper-1.txt, helper-2.txt, helper-3.txt. - -ls child-directory diff --git a/individual-shell-tools/ls/script-03.sh b/individual-shell-tools/ls/script-03.sh index b259fcb1d..781216d21 100755 --- a/individual-shell-tools/ls/script-03.sh +++ b/individual-shell-tools/ls/script-03.sh @@ -5,5 +5,3 @@ set -euo pipefail # TODO: Write a command which _recursively_ lists all of the files and folders in this directory _and_ all of the files inside those folders. # The output should be a list of names including: child-directory, script-01.sh, helper-1.txt (and more). # The formatting of the output doesn't matter. - -ls -R \ No newline at end of file diff --git a/individual-shell-tools/ls/script-04.sh b/individual-shell-tools/ls/script-04.sh index 061b4f3d0..72f3817b3 100755 --- a/individual-shell-tools/ls/script-04.sh +++ b/individual-shell-tools/ls/script-04.sh @@ -16,12 +16,8 @@ echo "First exercise (sorted newest to oldest):" # TODO: Write a command which lists the files in the child-directory directory, one per line, sorted so that the most recently modified file is first. # The output should be a list of names in this order, one per line: helper-3.txt, helper-1.txt, helper-2.txt. -ls -1t child-directory - echo "Second exercise (sorted oldest to newest):" # TODO: Write a command which does the same as above, but sorted in the opposite order (oldest first). # The output should be a list of names in this order, one per line: helper-2.txt, helper-1.txt, helper-3.txt. - -ls -1tr child-directory \ No newline at end of file diff --git a/individual-shell-tools/sed/script-01.sh b/individual-shell-tools/sed/script-01.sh index 0bd78a317..d592970fc 100755 --- a/individual-shell-tools/sed/script-01.sh +++ b/individual-shell-tools/sed/script-01.sh @@ -5,5 +5,3 @@ set -euo pipefail # TODO: Write a command to output input.txt with all occurrences of the letter `i` replaced with `I`. # The output should contain 11 lines. # The first line of the output should be: "ThIs Is a sample fIle for experImentIng wIth sed.". - -sed 's/i/I/g' input.txt \ No newline at end of file diff --git a/individual-shell-tools/sed/script-02.sh b/individual-shell-tools/sed/script-02.sh index 0f32ffd6b..abdd64d06 100755 --- a/individual-shell-tools/sed/script-02.sh +++ b/individual-shell-tools/sed/script-02.sh @@ -5,5 +5,3 @@ set -euo pipefail # TODO: Write a command to output input.txt with numbers removed. # The output should contain 11 lines. # Line 6 of the output should be " Alisha". - -sed 's/[0-9]*//g' input.txt \ No newline at end of file diff --git a/individual-shell-tools/sed/script-03.sh b/individual-shell-tools/sed/script-03.sh index e70f4a600..dd284a296 100755 --- a/individual-shell-tools/sed/script-03.sh +++ b/individual-shell-tools/sed/script-03.sh @@ -4,5 +4,3 @@ set -euo pipefail # TODO: Write a command to output input.txt removing any line which contains a number. # The output should contain 6 lines. - -sed '/[0-9]/d' input.txt diff --git a/individual-shell-tools/sed/script-04.sh b/individual-shell-tools/sed/script-04.sh index 8ac6e7c5d..0052ac6c4 100755 --- a/individual-shell-tools/sed/script-04.sh +++ b/individual-shell-tools/sed/script-04.sh @@ -4,5 +4,3 @@ set -euo pipefail # TODO: Write a command to output input.txt replacing every occurrence of the string "We'll" with "We will". # The output should contain 11 lines. - -sed "s/We'll/We will/g" input.txt diff --git a/individual-shell-tools/sed/script-05.sh b/individual-shell-tools/sed/script-05.sh index 990ac2f2c..2dcc91a0c 100755 --- a/individual-shell-tools/sed/script-05.sh +++ b/individual-shell-tools/sed/script-05.sh @@ -6,5 +6,3 @@ set -euo pipefail # If a line starts with a number and a space, make the line instead end with a space and the number. # So line 6 which currently reads "37 Alisha" should instead read "Alisha 37". # The output should contain 11 lines. - -sed -E 's/^([0-9]+) (.*)$/\2 \1/' input.txt diff --git a/individual-shell-tools/sed/script-06.sh b/individual-shell-tools/sed/script-06.sh index ab15800eb..0b9390170 100755 --- a/individual-shell-tools/sed/script-06.sh +++ b/individual-shell-tools/sed/script-06.sh @@ -8,5 +8,3 @@ set -euo pipefail # The output should contain 11 lines. # Line 3 should be "It contains many lines, and there are some things you may want to do with each of them.". # Line 11 should be "We also should remember, when we go shopping, to get 4 items: oranges, cheese, bread, olives.". - -sed 's/, */, /g' input.txt \ No newline at end of file diff --git a/individual-shell-tools/wc/script-01.sh b/individual-shell-tools/wc/script-01.sh index 22b7b8d9e..c9dd6e5df 100755 --- a/individual-shell-tools/wc/script-01.sh +++ b/individual-shell-tools/wc/script-01.sh @@ -4,5 +4,3 @@ set -euo pipefail # TODO: Write a command to output the number of words in the file helper-files/helper-3.txt. # The output should include the number 19. The output should not include the number 92. - -wc -w ../helper-files/helper-3.txt \ No newline at end of file diff --git a/individual-shell-tools/wc/script-02.sh b/individual-shell-tools/wc/script-02.sh index ae2ae870b..8feeb1a62 100755 --- a/individual-shell-tools/wc/script-02.sh +++ b/individual-shell-tools/wc/script-02.sh @@ -4,5 +4,3 @@ set -euo pipefail # TODO: Write a command to output the number of lines in the file helper-files/helper-3.txt. # The output should include the number 3. The output should not include the number 19. - -wc -l ../helper-files/helper-3.txt diff --git a/individual-shell-tools/wc/script-03.sh b/individual-shell-tools/wc/script-03.sh index 3bc287a1a..6b2e9d3d1 100755 --- a/individual-shell-tools/wc/script-03.sh +++ b/individual-shell-tools/wc/script-03.sh @@ -8,5 +8,3 @@ set -euo pipefail # 1 7 39 ../helper-files/helper-2.txt # 3 19 92 ../helper-files/helper-3.txt # 5 30 151 total - -wc ../helper-files/*.txt \ No newline at end of file From b6324e43bb4a2e65ac52046b6bb4dd410b73fd35 Mon Sep 17 00:00:00 2001 From: Boshra Mahmoudi Date: Tue, 28 Jul 2026 13:14:21 +0100 Subject: [PATCH 12/23] remove changes on main branch --- number-systems/Part-1.md | 32 ++++++++++++++++---------------- number-systems/Part-2.md | 12 +++++------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/number-systems/Part-1.md b/number-systems/Part-1.md index 68b77ea0b..d8f9c290e 100644 --- a/number-systems/Part-1.md +++ b/number-systems/Part-1.md @@ -6,49 +6,49 @@ The goal of these exercises is for you to gain an intuition for binary numbers. The answers to these questions should be a number, either in binary, hex, or decimal. -Q1: Convert the decimal number 14 to binary. 0,2,4,8,16,32,64,128,256 -Answer: 1110 +Q1: Convert the decimal number 14 to binary. +Answer: Q2: Convert the binary number 101101 to decimal: -Answer: 45 +Answer: Q3: Which is larger: 1000 or 0111? -Answer: 1000 +Answer: Q4: Which is larger: 00100 or 01011? -Answer: 01011 +Answer: Q5: What is 10101 + 01010? -Answer: 11111 +Answer: Q6: What is 10001 + 10001? -Answer: 100010 +Answer: Q7: What's the largest number you can store with 4 bits, if you want to be able to represent the number 0? -Answer: 15 +Answer: Q8: How many bits would you need in order to store the numbers between 0 and 255 inclusive? -Answer: 9 +Answer: Q9: How many bits would you need in order to store the numbers between 0 and 3 inclusive? -Answer: 2 +Answer: Q10: How many bits would you need in order to store the numbers between 0 and 1000 inclusive? -Answer: 10 +Answer: Q11: Convert the decimal number 14 to hex. -Answer: E +Answer: Q12: Convert the decimal number 386 to hex. -Answer: 182 +Answer: Q13: Convert the hex number 386 to decimal. -Answer: 902 +Answer: Q14: Convert the hex number B to decimal. -Answer: 11 +Answer: Q15: If reading the byte 0x21 as a number, what decimal number would it mean? -Answer: 33 +Answer: Q16: Continues in Part-2 diff --git a/number-systems/Part-2.md b/number-systems/Part-2.md index 1fce42ee7..68b0933d9 100644 --- a/number-systems/Part-2.md +++ b/number-systems/Part-2.md @@ -7,18 +7,16 @@ The goal of these exercises is for you to gain an intuition for binary numbers. The answers to these questions will require a bit of explanation, not just a simple answer. Q16: How can you test if a binary number is a power of two (e.g. 1, 2, 4, 8, 16, ...)? -Answer: If there is just one 1 in a binary number, then it is a power of 2. This is because each bit represents a power of 2, so if there is just one 1 bit in a binary number, the value represents a power of 2. +Answer: Q17: If reading the byte 0x21 as an ASCII character, what character would it mean? -Answer: ! +Answer: Q18: If reading the byte 0x21 as a greyscale colour, as described in "Approaches for Representing Colors and Images", what colour would it mean? -Answer: It represents 33, which is in the range of 0–255 from dark to light. This value represents a very dark grey. +Answer: Q19: If reading the bytes 0xAA00FF as a sequence of three one-byte decimal numbers, what decimal numbers would they be? -Answer: three one-byte => -AA | 00 | FF ==> AA : 10 * 16 + 10 * 1 = 170 | 00 : 0 * 16 + 0 * 1 = 0 | FF : 15 * 16 + 15 * 1 = 255 -so it reperesnt 170, 0, 255 +Answer: Q20: If reading the bytes 0xAA00FF as an RGB colour, as described in "Approaches for Representing Colors and Images", what colour would it mean? -Answer: AA => 170 Red, 00 => 0 green , FF : 255 is blue +Answer: From 31364b4bb140180269c9b2a8aaa009071f7f6e9a Mon Sep 17 00:00:00 2001 From: Boshra Mahmoudi Date: Tue, 28 Jul 2026 13:48:49 +0100 Subject: [PATCH 13/23] update script-01 file to be unchaged on main branch --- individual-shell-tools/ls/script-01.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/individual-shell-tools/ls/script-01.sh b/individual-shell-tools/ls/script-01.sh index 754a44837..3e5cb6eed 100755 --- a/individual-shell-tools/ls/script-01.sh +++ b/individual-shell-tools/ls/script-01.sh @@ -12,5 +12,4 @@ if [[ "${script_dir}" != "$(pwd)" ]]; then fi # TODO: Write a command to list the files and folders in this directory. - # The output should be a list of names including child-directory, script-01.sh, script-02.sh, and more. \ No newline at end of file From ebca147ad05ff59d69f3fe3f9bfc1ff824b6b812 Mon Sep 17 00:00:00 2001 From: Boshra Mahmoudi Date: Tue, 28 Jul 2026 17:52:45 +0100 Subject: [PATCH 14/23] fix unwanted file chnage --- individual-shell-tools/ls/script-01.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/individual-shell-tools/ls/script-01.sh b/individual-shell-tools/ls/script-01.sh index 3e5cb6eed..241b62f5e 100755 --- a/individual-shell-tools/ls/script-01.sh +++ b/individual-shell-tools/ls/script-01.sh @@ -12,4 +12,4 @@ if [[ "${script_dir}" != "$(pwd)" ]]; then fi # TODO: Write a command to list the files and folders in this directory. -# The output should be a list of names including child-directory, script-01.sh, script-02.sh, and more. \ No newline at end of file +# The output should be a list of names including child-directory, script-01.sh, script-02.sh, and more. From 61dafbb8810a01bdc0051acb636b6f237a06ed46 Mon Sep 17 00:00:00 2001 From: Boshra Mahmoudi Date: Mon, 31 Aug 2026 23:55:45 +0100 Subject: [PATCH 15/23] exercise1:Type checking with mypy --- sprint5/Exercise1.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 sprint5/Exercise1.py diff --git a/sprint5/Exercise1.py b/sprint5/Exercise1.py new file mode 100644 index 000000000..a469128c4 --- /dev/null +++ b/sprint5/Exercise1.py @@ -0,0 +1,30 @@ +def open_account(balances: dict[str,int], name: str, amount: int) -> None: + balances[name] = amount + +def sum_balances(accounts: dict[str, int]) -> int: + total = 0 + for name, pence in accounts.items(): + print(f"{name} had balance {pence}") + total += pence + return total + +def format_pence_as_string(total_pence: int) -> str: + if total_pence < 100: + return f"{total_pence}p" + pounds = int(total_pence / 100) + pence = total_pence % 100 + return f"£{pounds}.{pence:02d}" + +balances = { + "Sima": 700, + "Linn": 545, + "Georg": 831, +} + +open_account(balances, "Tobi", 913) +open_account(balances, "Olya", 713) + +total_pence = sum_balances(balances) +total_string = format_pence_as_string(total_pence) + +print(f"The bank accounts total {total_string}") \ No newline at end of file From a4b84ee551044caf85e34cc32de61acfa4a23024 Mon Sep 17 00:00:00 2001 From: Boshra Mahmoudi Date: Mon, 31 Aug 2026 23:56:20 +0100 Subject: [PATCH 16/23] exercise2: Classes and objects --- sprint5/Exercise2.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 sprint5/Exercise2.py diff --git a/sprint5/Exercise2.py b/sprint5/Exercise2.py new file mode 100644 index 000000000..71e2f8a2e --- /dev/null +++ b/sprint5/Exercise2.py @@ -0,0 +1,22 @@ +class Person: + def __init__(self, name: str, age: int, preferred_operating_system: str): + self.name = name + self.age = age + self.preferred_operating_system = preferred_operating_system + +imran = Person("Imran", 22, "Ubuntu") +print(imran.name) +print(imran.age) +print(imran.preferred_operating_system) + + +eliza = Person("Eliza", 34, "Arch Linux") +print(eliza.name) + +def is_adult(person: Person) -> bool: + return person.age >= 18 + +print(is_adult(imran)) + + def get_address(person: Person) -> str: #this returns an error + return person.address From e98a5713424d9c00114eb4183010a06e70fbed78 Mon Sep 17 00:00:00 2001 From: Boshra Mahmoudi Date: Tue, 1 Sep 2026 00:41:17 +0100 Subject: [PATCH 17/23] method exercise --- sprint5/Methods.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 sprint5/Methods.py diff --git a/sprint5/Methods.py b/sprint5/Methods.py new file mode 100644 index 000000000..32bf47c14 --- /dev/null +++ b/sprint5/Methods.py @@ -0,0 +1,29 @@ +from datetime import date + + +class Person: + def __init__(self, name: str, date_of_birth: date, preferred_operating_system: str): + self.name = name + self.date_of_birth = date_of_birth + self.preferred_operating_system = preferred_operating_system + + def is_adult(self) -> bool: + today = date.today() + + age = today.year - self.date_of_birth.year + + if (today.month, today.day) < ( + self.date_of_birth.month, + self.date_of_birth.day + ): + age -= 1 + + return age >= 18 + +imran = Person( + "Imran", + date(2000, 5, 10), + "Ubuntu" +) + +print(imran.is_adult()) \ No newline at end of file From aaf5689aabc3b8a84da487c29b3bd16473032634 Mon Sep 17 00:00:00 2001 From: Boshra Mahmoudi Date: Tue, 1 Sep 2026 01:29:39 +0100 Subject: [PATCH 18/23] dataclasses exercise --- sprint5/dataclasses-example.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 sprint5/dataclasses-example.py diff --git a/sprint5/dataclasses-example.py b/sprint5/dataclasses-example.py new file mode 100644 index 000000000..a1f77f7dd --- /dev/null +++ b/sprint5/dataclasses-example.py @@ -0,0 +1,32 @@ +from dataclasses import dataclass +from datetime import date + + +@dataclass(frozen=True) +class Person: + name: str + date_of_birth: date + preferred_operating_system: str + + def is_adult(self) -> bool: + today = date.today() + + age = today.year - self.date_of_birth.year + + if (today.month, today.day) < ( + self.date_of_birth.month, + self.date_of_birth.day, + ): + age -= 1 + + return age >= 18 + + +imran = Person( + "Imran", + date(2000, 5, 10), + "Ubuntu" +) + +print(imran) +print(imran.is_adult()) \ No newline at end of file From aa9fa7c364d95e444b6791ada056da02827dfaf4 Mon Sep 17 00:00:00 2001 From: Boshra Mahmoudi Date: Tue, 1 Sep 2026 01:41:57 +0100 Subject: [PATCH 19/23] generics exercise --- sprint5/generics.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 sprint5/generics.py diff --git a/sprint5/generics.py b/sprint5/generics.py new file mode 100644 index 000000000..e660ec7c7 --- /dev/null +++ b/sprint5/generics.py @@ -0,0 +1,20 @@ +from dataclasses import dataclass +from typing import List + +@dataclass(frozen=True) +class Person: + name: str + age: int + children: List["Person"] + +fatma = Person(name="Fatma", age=10, children=[]) +aisha = Person(name="Aisha", age=5 ,children=[]) + +imran = Person(name="Imran", age=40, children=[fatma, aisha]) + +def print_family_tree(person: Person) -> None: + print(person.name) + for child in person.children: + print(f"- {child.name} ({child.age})") + +print_family_tree(imran) \ No newline at end of file From 200002b29771ff02c0882bc547577187f2bae6e8 Mon Sep 17 00:00:00 2001 From: Boshra Mahmoudi Date: Tue, 1 Sep 2026 01:59:46 +0100 Subject: [PATCH 20/23] Type-guided refactorings exercise --- sprint5/type-guided-refactorings.py | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 sprint5/type-guided-refactorings.py diff --git a/sprint5/type-guided-refactorings.py b/sprint5/type-guided-refactorings.py new file mode 100644 index 000000000..784ad68f4 --- /dev/null +++ b/sprint5/type-guided-refactorings.py @@ -0,0 +1,42 @@ +from dataclasses import dataclass +from typing import List + +@dataclass(frozen=True) +class Person: + name: str + age: int + preferred_operating_systems: List[str] + + +@dataclass(frozen=True) +class Laptop: + id: int + manufacturer: str + model: str + screen_size_in_inches: float + operating_system: str + + +def find_possible_laptops(laptops: List[Laptop], person: Person) -> List[Laptop]: + possible_laptops = [] + for laptop in laptops: + if laptop.operating_system in person.preferred_operating_systems: + possible_laptops.append(laptop) + return possible_laptops + + +people = [ + Person(name="Imran", age=22, preferred_operating_systems=["Ubuntu", "Arch Linux"]), + Person(name="Eliza", age=34, preferred_operating_systems=["Arch Linux"]), +] + +laptops = [ + Laptop(id=1, manufacturer="Dell", model="XPS", screen_size_in_inches=13, operating_system="Arch Linux"), + Laptop(id=2, manufacturer="Dell", model="XPS", screen_size_in_inches=15, operating_system="Ubuntu"), + Laptop(id=3, manufacturer="Dell", model="XPS", screen_size_in_inches=15, operating_system="ubuntu"), + Laptop(id=4, manufacturer="Apple", model="macBook", screen_size_in_inches=13, operating_system="macOS"), +] + +for person in people: + possible_laptops = find_possible_laptops(laptops, person) + print(f"Possible laptops for {person.name}: {possible_laptops}") \ No newline at end of file From 2ba06cca19e48d0085c89822a367de7f54c07d54 Mon Sep 17 00:00:00 2001 From: Boshra Mahmoudi Date: Tue, 1 Sep 2026 16:02:22 +0100 Subject: [PATCH 21/23] enums exercise --- sprint5/enums.py | 84 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 sprint5/enums.py diff --git a/sprint5/enums.py b/sprint5/enums.py new file mode 100644 index 000000000..9e8259c1d --- /dev/null +++ b/sprint5/enums.py @@ -0,0 +1,84 @@ +from dataclasses import dataclass +from enum import Enum +import sys + + +class OperatingSystem(Enum): + MACOS = "macOS" + ARCH = "Arch Linux" + UBUNTU = "Ubuntu" + + +@dataclass(frozen=True) +class Person: + name: str + age: int + preferred_operating_system: OperatingSystem + + +@dataclass(frozen=True) +class Laptop: + id: int + manufacturer: str + model: str + screen_size_in_inches: float + operating_system: OperatingSystem + + + +laptops = [ + Laptop(1, "Dell", "XPS", 13, OperatingSystem.ARCH), + Laptop(2, "Dell", "XPS", 15, OperatingSystem.UBUNTU), + Laptop(3, "Dell", "XPS", 15, OperatingSystem.UBUNTU), + Laptop(4, "Apple", "MacBook", 13, OperatingSystem.MACOS), +] + + +name = input("What is your name? ") + +try: + age = int(input("What is your age? ")) +except ValueError: + print("Age must be a number.", file=sys.stderr) + sys.exit(1) + + +try: + operating_system = input("What operating system do you prefer? ") + preferred_operating_system = OperatingSystem(operating_system) +except ValueError: + print("That is not a valid operating system.", file=sys.stderr) + sys.exit(1) + + +person = Person( + name, + age, + preferred_operating_system +) + +number_of_laptops = 0 + +for laptop in laptops: + if laptop.operating_system == person.preferred_operating_system: + number_of_laptops += 1 + + +print( + f"There are {number_of_laptops} " + f"{person.preferred_operating_system.value} laptops available." +) + +for operating_system in OperatingSystem: + number_available = 0 + + for laptop in laptops: + if laptop.operating_system == operating_system: + number_available += 1 + + if number_available > number_of_laptops: + print( + f"You are more likely to get a laptop if you " + f"are willing to use {operating_system.value}." + ) + From b3a54f362159254d438069fb473511325a588d15 Mon Sep 17 00:00:00 2001 From: Boshra Mahmoudi Date: Wed, 2 Sep 2026 00:10:44 +0100 Subject: [PATCH 22/23] Inheritance exercise --- sprint5/Inheritance.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 sprint5/Inheritance.py diff --git a/sprint5/Inheritance.py b/sprint5/Inheritance.py new file mode 100644 index 000000000..c80f5448f --- /dev/null +++ b/sprint5/Inheritance.py @@ -0,0 +1,38 @@ +class Parent: + def __init__(self, first_name: str, last_name: str): + self.first_name = first_name + self.last_name = last_name + + def get_name(self) -> str: + return f"{self.first_name} {self.last_name}" + + +class Child(Parent): + def __init__(self, first_name: str, last_name: str): + super().__init__(first_name, last_name) + self.previous_last_names = [] + + def change_last_name(self, last_name) -> None: + self.previous_last_names.append(self.last_name) + self.last_name = last_name + + def get_full_name(self) -> str: + suffix = "" + if len(self.previous_last_names) > 0: + suffix = f" (née {self.previous_last_names[0]})" + return f"{self.first_name} {self.last_name}{suffix}" + +person1 = Child("Elizaveta", "Alekseeva") +print("1",person1.get_name()) # It should print "Elizaveta Alekseeva" +print("2",person1.get_full_name()) # It should print "Elizaveta Alekseeva" +person1.change_last_name("Tyurina") # Changes the last name to "Tyurina" +print("3",person1.get_name())# It should print "Elizaveta Alekseeva" # I was wrong here because the child's last_name has been changed to "Tyurina". +print("4",person1.get_full_name())# I thought it would print "Elizaveta Alekseeva (née Tyurina)" +# I was wrong here again because I misunderstood how last_name and previous_last_names work. + +person2 = Parent("Elizaveta", "Alekseeva") +print("5",person2.get_name()) # It should print "Elizaveta Alekseeva" +print("6",person2.get_full_name()) # Returns an error because Parent doesn't have a get_full_name() method. +person2.change_last_name("Tyurina") # Returns an error because Parent doesn't have a change_last_name() method. +print("7",person2.get_name()) # It should print "Elizaveta Alekseeva" +print(person2.get_full_name()) # returns an error again because Parent doesn't have a get_full_name() method. \ No newline at end of file From f828703d5a9ff81224d50f3aea46c3d73a55cdfa Mon Sep 17 00:00:00 2001 From: Boshra Mahmoudi Date: Thu, 3 Sep 2026 14:03:18 +0100 Subject: [PATCH 23/23] Improve code using Python built-in methods and floor division --- sprint5/Exercise1.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sprint5/Exercise1.py b/sprint5/Exercise1.py index a469128c4..898aab966 100644 --- a/sprint5/Exercise1.py +++ b/sprint5/Exercise1.py @@ -2,17 +2,15 @@ def open_account(balances: dict[str,int], name: str, amount: int) -> None: balances[name] = amount def sum_balances(accounts: dict[str, int]) -> int: - total = 0 for name, pence in accounts.items(): print(f"{name} had balance {pence}") - total += pence - return total + return sum(accounts.values()) def format_pence_as_string(total_pence: int) -> str: if total_pence < 100: return f"{total_pence}p" - pounds = int(total_pence / 100) - pence = total_pence % 100 + pounds = total_pence // 100 + pence = total_pence % 100 return f"£{pounds}.{pence:02d}" balances = {