From f95ea5ccacb9d3d7dd494ed7d17bda33c8c44547 Mon Sep 17 00:00:00 2001 From: Shivam Tiwari Date: Thu, 10 Jul 2025 00:51:44 +0530 Subject: [PATCH 1/3] feat:new examples --- Day-02/examples/03-regex-findall.py | 89 ++++++++++++++++++++++++++--- Day-02/examples/test.py | 4 ++ 2 files changed, 85 insertions(+), 8 deletions(-) create mode 100644 Day-02/examples/test.py diff --git a/Day-02/examples/03-regex-findall.py b/Day-02/examples/03-regex-findall.py index ec5cdd5c..94270ba6 100644 --- a/Day-02/examples/03-regex-findall.py +++ b/Day-02/examples/03-regex-findall.py @@ -1,10 +1,83 @@ import re -text = "The quick brown fox" -pattern = r"brown" - -search = re.search(pattern, text) -if search: - print("Pattern found:", search.group()) -else: - print("Pattern not found") +# BEGINNER REGEX EXAMPLES - Step by Step Learning + +print("=== BASIC REGEX PATTERNS ===\n") + +# Example 1: Finding simple words +text1 = "I love Python programming and Python is easy" +pattern1 = r"Python" # Just finds the exact word "Python" +matches1 = re.findall(pattern1, text1) +print(f"Text: {text1}") +print(f"Pattern: {pattern1}") +print(f"Matches: {matches1}") +print() + +# Example 2: Finding digits +text2 = "I have 5 apples and 10 oranges" +pattern2 = r"\d" # \d means any digit (0-9) +matches2 = re.findall(pattern2, text2) +print(f"Text: {text2}") +print(f"Pattern: {pattern2} (\\d means any digit)") +print(f"Matches: {matches2}") +print() + +# Example 3: Finding multiple digits together +text3 = "I have 25 apples and 100 oranges" +pattern3 = r"\d+" # \d+ means one or more digits together +matches3 = re.findall(pattern3, text3) +print(f"Text: {text3}") +print(f"Pattern: {pattern3} (\\d+ means one or more digits)") +print(f"Matches: {matches3}") +print() + +# Example 4: Finding words (letters only) +text4 = "Hello123 World456 Python" +pattern4 = r"[a-zA-Z]+" # [a-zA-Z]+ means one or more letters +matches4 = re.findall(pattern4, text4) +print(f"Text: {text4}") +print(f"Pattern: {pattern4} (letters only)") +print(f"Matches: {matches4}") +print() + +# Example 5: Finding words that start with capital letter +text5 = "Python is Great for Data Science" +pattern5 = r"[A-Z][a-z]+" # [A-Z] = capital letter, [a-z]+ = lowercase letters +matches5 = re.findall(pattern5, text5) +print(f"Text: {text5}") +print(f"Pattern: {pattern5} (capital letter + lowercase letters)") +print(f"Matches: {matches5}") +print() + +# Example 6: Finding email pattern (simplified) +text6 = "Contact me at john@gmail.com or mary@yahoo.com" +pattern6 = r"\w+@\w+\.\w+" # \w+ = word characters, @ = literal @, \. = literal dot +matches6 = re.findall(pattern6, text6) +print(f"Text: {text6}") +print(f"Pattern: {pattern6} (word@word.word)") +print(f"Matches: {matches6}") +print() + +# Example 7: Finding phone numbers (simple pattern) +text7 = "Call me at 123-456-7890 or 555-123-4567" +pattern7 = r"\d{3}-\d{3}-\d{4}" # \d{3} = exactly 3 digits +matches7 = re.findall(pattern7, text7) +print(f"Text: {text7}") +print(f"Pattern: {pattern7} (3digits-3digits-4digits)") +print(f"Matches: {matches7}") +print() + +print("=== REGEX CHEAT SHEET ===") +print("\\d = any digit (0-9)") +print("\\w = any word character (letters, digits, underscore)") +print("\\s = any whitespace (space, tab, newline)") +print("+ = one or more of the previous character") +print("* = zero or more of the previous character") +print("? = zero or one of the previous character") +print("{3} = exactly 3 of the previous character") +print("[a-z] = any lowercase letter") +print("[A-Z] = any uppercase letter") +print("[0-9] = any digit (same as \\d)") +print(". = any character except newline") +print("^ = start of string") +print("$ = end of string") diff --git a/Day-02/examples/test.py b/Day-02/examples/test.py new file mode 100644 index 00000000..ea37f2a2 --- /dev/null +++ b/Day-02/examples/test.py @@ -0,0 +1,4 @@ +name="shivam" +name1="tiwari" +print(name+" "+name1) +print(len(name+name1)) From 32e07538025088ba085be884454d8e3c5cb5484d Mon Sep 17 00:00:00 2001 From: Shivam Tiwari Date: Fri, 24 Apr 2026 12:08:59 +0530 Subject: [PATCH 2/3] chore : just checking --- Day-02/examples/03-regex-findall.py | 65 +++++++++++++ Day-02/examples/03-regex-match.py | 116 ++++++++++++++++++++++- Day-08/02-Assigment/01-list-questions.md | 6 -- 3 files changed, 176 insertions(+), 11 deletions(-) diff --git a/Day-02/examples/03-regex-findall.py b/Day-02/examples/03-regex-findall.py index 94270ba6..6d3b7848 100644 --- a/Day-02/examples/03-regex-findall.py +++ b/Day-02/examples/03-regex-findall.py @@ -1,5 +1,70 @@ import re +# UNDERSTANDING RAW STRINGS (r"") +print("=== WHAT DOES 'r' MEAN BEFORE STRINGS? ===\n") + +# The 'r' creates a RAW STRING - it treats backslashes literally +# This is very important for regex patterns! + +# Example: Regular string vs Raw string +print("Regular string:") +regular_string = "Hello\nWorld" # \n is interpreted as newline +print(f"'{regular_string}'") +print() + +print("Raw string:") +raw_string = r"Hello\nWorld" # \n is treated as literal characters +print(f"'{raw_string}'") +print() + +# Why is this important for regex? +print("=== WHY RAW STRINGS ARE IMPORTANT FOR REGEX ===\n") + +# Example 1: Finding backslashes in text +text_with_backslash = "File path: C:\\Users\\John\\Documents" +print(f"Text: {text_with_backslash}") + +# Without raw string - CONFUSING! +pattern_normal = "\\\\Users" # Need 4 backslashes to match 2! +matches_normal = re.findall(pattern_normal, text_with_backslash) +print(f"Normal string pattern: '{pattern_normal}'") +print(f"Matches: {matches_normal}") + +# With raw string - CLEAR! +pattern_raw = r"\\Users" # Only need 2 backslashes +matches_raw = re.findall(pattern_raw, text_with_backslash) +print(f"Raw string pattern: '{pattern_raw}'") +print(f"Matches: {matches_raw}") +print() + +# Example 2: Digit patterns +print("=== DIGIT PATTERNS EXAMPLE ===") +text_digits = "I have 25 apples and 100 oranges" +print(f"Text: {text_digits}") + +# Both work the same for simple patterns like \d +pattern_normal_digit = "\\d+" # Need to escape the backslash +pattern_raw_digit = r"\d+" # Raw string - cleaner and more readable + +matches_normal_digit = re.findall(pattern_normal_digit, text_digits) +matches_raw_digit = re.findall(pattern_raw_digit, text_digits) + +print(f"Normal string: '{pattern_normal_digit}' -> {matches_normal_digit}") +print(f"Raw string: '{pattern_raw_digit}' -> {matches_raw_digit}") +print() + +print("=== KEY POINTS ABOUT RAW STRINGS ===") +print("1. Raw strings treat backslashes (\\) as literal characters") +print("2. Regular strings interpret backslashes as escape characters") +print("3. Raw strings make regex patterns much more readable") +print("4. Always use raw strings for regex patterns: r'pattern'") +print("5. Examples of escape characters in regular strings:") +print(" \\n = newline") +print(" \\t = tab") +print(" \\' = single quote") +print(" \\\\ = literal backslash") +print() + # BEGINNER REGEX EXAMPLES - Step by Step Learning print("=== BASIC REGEX PATTERNS ===\n") diff --git a/Day-02/examples/03-regex-match.py b/Day-02/examples/03-regex-match.py index b3aafdd1..917ead6a 100644 --- a/Day-02/examples/03-regex-match.py +++ b/Day-02/examples/03-regex-match.py @@ -1,10 +1,116 @@ import re -text = "The quick brown fox" -pattern = r"quick" +# REGEX MATCH EXAMPLES - Beginner Friendly -match = re.match(pattern, text) -if match: - print("Match found:", match.group()) +print("=== UNDERSTANDING re.match() ===") +print("re.match() only matches at the BEGINNING of the string\n") + +# Example 1: Basic match - Success case +text1 = "Python is awesome" +pattern1 = r"Python" +match1 = re.match(pattern1, text1) +print(f"Text: '{text1}'") +print(f"Pattern: '{pattern1}'") +if match1: + print(f"Match found: '{match1.group()}'") + print(f"Match position: {match1.start()}-{match1.end()}") +else: + print("No match") +print() + +# Example 2: Basic match - Failure case +text2 = "I love Python programming" +pattern2 = r"Python" +match2 = re.match(pattern2, text2) +print(f"Text: '{text2}'") +print(f"Pattern: '{pattern2}'") +if match2: + print(f"Match found: '{match2.group()}'") +else: + print("No match (Python is not at the beginning)") +print() + +# Example 3: Matching numbers at the start +text3 = "123 Main Street" +pattern3 = r"\d+" # \d+ means one or more digits +match3 = re.match(pattern3, text3) +print(f"Text: '{text3}'") +print(f"Pattern: '{pattern3}' (one or more digits)") +if match3: + print(f"Match found: '{match3.group()}'") +else: + print("No match") +print() + +# Example 4: Matching email format from start +text4 = "john@example.com sent you a message" +pattern4 = r"\w+@\w+\.\w+" # simple email pattern +match4 = re.match(pattern4, text4) +print(f"Text: '{text4}'") +print(f"Pattern: '{pattern4}' (email format)") +if match4: + print(f"Match found: '{match4.group()}'") +else: + print("No match") +print() + +# Example 5: Matching phone number at start +text5 = "123-456-7890 is my phone number" +pattern5 = r"\d{3}-\d{3}-\d{4}" # phone number format +match5 = re.match(pattern5, text5) +print(f"Text: '{text5}'") +print(f"Pattern: '{pattern5}' (phone format)") +if match5: + print(f"Match found: '{match5.group()}'") else: print("No match") +print() + +# Example 6: Case sensitivity +text6 = "python is great" +pattern6 = r"Python" # Capital P +match6 = re.match(pattern6, text6) +print(f"Text: '{text6}'") +print(f"Pattern: '{pattern6}' (case sensitive)") +if match6: + print(f"Match found: '{match6.group()}'") +else: + print("No match (case sensitive - 'python' != 'Python')") +print() + +# Example 7: Case insensitive matching +text7 = "python is great" +pattern7 = r"Python" +match7 = re.match(pattern7, text7, re.IGNORECASE) # Case insensitive flag +print(f"Text: '{text7}'") +print(f"Pattern: '{pattern7}' (case insensitive)") +if match7: + print(f"Match found: '{match7.group()}'") +else: + print("No match") +print() + +print("=== COMPARISON: match() vs search() vs findall() ===") +test_text = "Hello Python world, Python is amazing" +test_pattern = r"Python" + +print(f"Text: '{test_text}'") +print(f"Pattern: '{test_pattern}'") + +# Using match() +match_result = re.match(test_pattern, test_text) +print(f"re.match(): {match_result.group() if match_result else 'No match'}") + +# Using search() +search_result = re.search(test_pattern, test_text) +print(f"re.search(): {search_result.group() if search_result else 'No match'}") + +# Using findall() +findall_result = re.findall(test_pattern, test_text) +print(f"re.findall(): {findall_result}") + +print("\n=== KEY POINTS ===") +print("1. re.match() only matches at the START of the string") +print("2. re.search() finds the FIRST occurrence anywhere in the string") +print("3. re.findall() finds ALL occurrences in the string") +print("4. Use re.IGNORECASE flag for case-insensitive matching") diff --git a/Day-08/02-Assigment/01-list-questions.md b/Day-08/02-Assigment/01-list-questions.md index 8ca5ea75..e36db5c8 100644 --- a/Day-08/02-Assigment/01-list-questions.md +++ b/Day-08/02-Assigment/01-list-questions.md @@ -4,11 +4,5 @@ **Q2: How do you create a list in Python, and can you provide an example related to DevOps?** -**Q3: What is the difference between a list and a tuple in Python, and when would you choose one over the other in a DevOps context?** -**Q4: How can you access elements in a list, and provide a DevOps-related example?** - -**Q5: How do you add an element to the end of a list in Python? Provide a DevOps example.** - -**Q6: How can you remove an element from a list in Python, and can you provide a DevOps use case?** From 5452212bdf4ff9563ff3c3e34de4d9293ef3a33b Mon Sep 17 00:00:00 2001 From: Shivam Tiwari Date: Fri, 24 Apr 2026 12:11:55 +0530 Subject: [PATCH 3/3] chore : skiills.md --- .claude/skills/code-pr/SKILL.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .claude/skills/code-pr/SKILL.md diff --git a/.claude/skills/code-pr/SKILL.md b/.claude/skills/code-pr/SKILL.md new file mode 100644 index 00000000..61c7c9be --- /dev/null +++ b/.claude/skills/code-pr/SKILL.md @@ -0,0 +1,19 @@ +--- + +name : code-pr +description: write a pr description when new pr is created or someone asks to review a pr or writing a pr + +--- + +when writing a pr description + +1. Run 'git diff main...HEAD" to see all the changes on this branch +2. write a description following this format + +## what + +one sentence explaining what this pr is + +## why + +brief why it is neede \ No newline at end of file