Skip to content

Commit 6c801e3

Browse files
committed
day 15 code is updated
1 parent 80b0bbc commit 6c801e3

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

Status/Day_15.md

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@ print r2.group(2)
3434
----------------
3535
**My Solution: Python 3**
3636
```python
37-
#to be written
37+
import re
3838

39+
40+
pattern = "\w+@(\w+).com"
41+
ans = re.findall(pattern,email)
42+
print(ans)
3943
```
4044
---------------------
4145

@@ -73,8 +77,27 @@ print re.findall("\d+",s)
7377
----------------
7478
**My Solution: Python 3**
7579
```python
76-
#to be written
80+
import re
7781

82+
email = input()
83+
pattern = "\d+"
84+
ans = re.findall(pattern,email)
85+
print(ans)
86+
```
87+
**OR**
88+
```python
89+
email = input().split()
90+
ans = []
91+
for word in email:
92+
if word.isdigit(): # can also use isnumeric() / isdecimal() function instead
93+
ans.append(word)
94+
print(ans)
95+
```
96+
**OR**
97+
```python
98+
email = input().split()
99+
ans = [word for word in email if word.isdigit()] # using list comprehension method
100+
print(ans)
78101
```
79102
---------------------
80103

@@ -98,12 +121,6 @@ unicodeString = u"hello world!"
98121
print unicodeString
99122
```
100123
----------------
101-
**My Solution: Python 3**
102-
```python
103-
#to be written
104-
105-
```
106-
---------------------
107124

108125
# Question 57
109126

@@ -113,7 +130,7 @@ print unicodeString
113130
114131
----------------------
115132
### Hints
116-
> ***Use unicode() function to convert.***
133+
> ***Use unicode()/encode() function to convert.***
117134
118135
----------------------
119136

@@ -126,8 +143,9 @@ print u
126143
----------------
127144
**My Solution: Python 3**
128145
```python
129-
#to be written
130-
146+
s = input()
147+
u = s.encode('utf-8')
148+
print(u)
131149
```
132150
---------------------
133151

@@ -168,7 +186,7 @@ If the following n is given as input to the program:***
168186

169187
----------------------
170188
### Hints
171-
> ***Use float() to convert an integer to a float***
189+
> ***Use float() to convert an integer to a float.Even if not converted it wont cause a problem because python by default understands the data type of a value***
172190
173191
----------------------
174192

@@ -183,7 +201,10 @@ print sum
183201
----------------
184202
**My Solution: Python 3**
185203
```python
186-
#to be written
187-
204+
n = int(input())
205+
sum = 0
206+
for i in range(1, n+1):
207+
sum+= i/(i+1)
208+
print(sum)
188209
```
189210
---------------------

0 commit comments

Comments
 (0)