diff --git a/Day-01/test1.py b/Day-01/test1.py new file mode 100644 index 00000000..bc7aabaa --- /dev/null +++ b/Day-01/test1.py @@ -0,0 +1,3 @@ +print ("This is praveen's first program in python") +print ("This is the sencond line in the program that gets printed on the screen") +print ("This is the third line") diff --git a/Day-02/examples/02-float.py b/Day-02/examples/02-float.py index 8d6264c4..4a043af7 100644 --- a/Day-02/examples/02-float.py +++ b/Day-02/examples/02-float.py @@ -17,4 +17,4 @@ # Rounding result5 = round(3.14159265359, 2) # Rounds to 2 decimal places -print("Rounded:", result5) +print("Rounded:", result5) \ No newline at end of file diff --git a/Day-02/examples/03-regex-match.py b/Day-02/examples/03-regex-match.py index b3aafdd1..7f8314d5 100644 --- a/Day-02/examples/03-regex-match.py +++ b/Day-02/examples/03-regex-match.py @@ -7,4 +7,4 @@ if match: print("Match found:", match.group()) else: - print("No match") + print("No match") \ No newline at end of file diff --git a/Day-02/examples/all-strings.py b/Day-02/examples/all-strings.py new file mode 100644 index 00000000..bd296f01 --- /dev/null +++ b/Day-02/examples/all-strings.py @@ -0,0 +1,29 @@ +str1 = "The textbooks are good for reading" +str1 = str1.replace("good","great") + +str2 = "arn:123456:role/james" +str2 = str2.split("/") + +str3 = " I am padded with a transparent gown. You can see me. But not feel it " +str_stripped = str3.strip() + +## Looks like there is NO substring function in Python" The way to find is as below +str4 = "Welcome to the beautiful world of computers" +str5 = "Bountiful" + +if str5 in str4: + print("beautiful is found") +else: + print("beautiful is NOT found") + +print(str1) +print(str2) +print(str2[0]) +print(str2[1]) +print("------------------------") +print(len(str3)) +print(str_stripped) +print(len(str_stripped)) + + + diff --git a/Day-02/examples/concat.py b/Day-02/examples/concat.py new file mode 100644 index 00000000..798a6924 --- /dev/null +++ b/Day-02/examples/concat.py @@ -0,0 +1,5 @@ +s1 = "Hello" +s2 = "Praveen" +con = s1 + " " + "Indiana Jones" + " " + "Kurra" + " " + s2 +print(con) + diff --git a/Day-02/examples/division.py b/Day-02/examples/division.py new file mode 100644 index 00000000..0109c98c --- /dev/null +++ b/Day-02/examples/division.py @@ -0,0 +1,23 @@ +int1 = 5 +int2 = 2 + +print(int1 / int2) +print(int1 // int2) + +print("----------------------") + + +float1 = 5.0 +float2 = 2.0 + +print (float1 / float2) +print (float1 // float2) + +test1 = 12.5674 +res1 = round(test1, 1) +res2 = round(test1, 2) +res3 = round(test1,3) + +print(res1, res2, res3) + + diff --git a/Day-02/examples/integers.py b/Day-02/examples/integers.py new file mode 100644 index 00000000..3d311f91 --- /dev/null +++ b/Day-02/examples/integers.py @@ -0,0 +1,16 @@ +# Integer variables +num1 = 10 +num2 = 5 + +# Integer Division +result1 = num1 // num2 +print("Integer Division:", result1) + +# Modulus (Remainder) +result2 = num1 % num2 +print("Modulus (Remainder):", result2) + +# Absolute Value +result3 = abs(-7) +print("Absolute Value:", result3) + diff --git a/Day-02/examples/regex-all.py b/Day-02/examples/regex-all.py new file mode 100644 index 00000000..3a2c5f86 --- /dev/null +++ b/Day-02/examples/regex-all.py @@ -0,0 +1,38 @@ +import re + +str1 = "How many times I have to say you should not do it. Did you hear me?" + +pattern = r"you" + +res = re.search(pattern, str1) +# you should never write if res == True: or if res is True: +# Below is the right way of using bool in if condition. you can also say if not res: for negation + +if res : + print("your search pattern found", res.group()) +else: + print("didn't find your search pattern") + +# Difference between re.search and re.match in Python? + +# re.match() searches for matches from the beginning of a string while re.search() searches for matches anywhere in the string. + +# re.match attempts to match a pattern at the beginning of the string. re.search attempts to match the pattern throughout the string until it finds a match + +# Example: + +import re + +claim = 'People love Python.' + +print(re.search(r'Python', claim).group()) +# => Python + +print(re.match(r'Python', claim)) +# => None + +print(re.search(r'People', claim).group()) +# => People + +print(re.match(r'People', claim).group()) +# => People diff --git a/Day-02/examples/replace.py b/Day-02/examples/replace.py new file mode 100644 index 00000000..4e587c90 --- /dev/null +++ b/Day-02/examples/replace.py @@ -0,0 +1,12 @@ +import re +str1 = "Welcome to the world of good leaders" + +pattern = r"good" + +replacement = "bad" + +newstring = re.sub(pattern, replacement, str1) + +print(newstring) + + diff --git a/Day-02/examples/split.py b/Day-02/examples/split.py new file mode 100644 index 00000000..bfcaced1 --- /dev/null +++ b/Day-02/examples/split.py @@ -0,0 +1,11 @@ +# returns a list of resulting substrings +import re +str1 = "apple, banana, orange, grapes" + +pattern = r"," + +newstring = re.split(pattern, str1) + +print(newstring) + + diff --git a/Day-02/examples/upper_lower.py b/Day-02/examples/upper_lower.py new file mode 100644 index 00000000..17652083 --- /dev/null +++ b/Day-02/examples/upper_lower.py @@ -0,0 +1,12 @@ +text = "Quick mad fox jumps over a lazy hen" +str1 = "THIS IS ALL IN UPPER CASE" +str2 = "this is all in lower case" + +text1 = len(text) +res1 = str1.lower() +res2 = str2.upper() + +print (text1) +print (res1) +print (res2) + diff --git a/Day-02/strings.py b/Day-02/strings.py deleted file mode 100644 index e69de29b..00000000