Skip to content

Commit 01141da

Browse files
add files for day-2
1 parent 297ab48 commit 01141da

14 files changed

+106
-0
lines changed

Day-02/examples/01-string-concat.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
str1 = "Hello"
2+
str2 = "World"
3+
result = str1 + " " + str2
4+
print(result)

Day-02/examples/01-string-len.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
text = "Python is awesome"
2+
length = len(text)
3+
print("Length of the string:", length)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
text = "Python is awesome"
2+
uppercase = text.upper()
3+
lowercase = text.lower()
4+
print("Uppercase:", uppercase)
5+
print("Lowercase:", lowercase)

Day-02/examples/01-string-replace.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
text = "Python is awesome"
2+
new_text = text.replace("awesome", "great")
3+
print("Modified text:", new_text)

Day-02/examples/01-string-split.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
text = "Python is awesome"
2+
words = text.split()
3+
print("Words:", words)

Day-02/examples/01-string-strip.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
text = " Some spaces around "
2+
stripped_text = text.strip()
3+
print("Stripped text:", stripped_text)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
text = "Python is awesome"
2+
substring = "is"
3+
if substring in text:
4+
print(substring, "found in the text")

Day-02/examples/02-float.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Float variables
2+
num1 = 5.0
3+
num2 = 2.5
4+
5+
# Basic Arithmetic
6+
result1 = num1 + num2
7+
print("Addition:", result1)
8+
9+
result2 = num1 - num2
10+
print("Subtraction:", result2)
11+
12+
result3 = num1 * num2
13+
print("Multiplication:", result3)
14+
15+
result4 = num1 / num2
16+
print("Division:", result4)
17+
18+
# Rounding
19+
result5 = round(3.14159265359, 2) # Rounds to 2 decimal places
20+
print("Rounded:", result5)

Day-02/examples/02-int.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Integer variables
2+
num1 = 10
3+
num2 = 5
4+
5+
# Integer Division
6+
result1 = num1 // num2
7+
print("Integer Division:", result1)
8+
9+
# Modulus (Remainder)
10+
result2 = num1 % num2
11+
print("Modulus (Remainder):", result2)
12+
13+
# Absolute Value
14+
result3 = abs(-7)
15+
print("Absolute Value:", result3)

Day-02/examples/03-regex-findall.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import re
2+
3+
text = "The quick brown fox"
4+
pattern = r"brown"
5+
6+
search = re.search(pattern, text)
7+
if search:
8+
print("Pattern found:", search.group())
9+
else:
10+
print("Pattern not found")

0 commit comments

Comments
 (0)