Skip to content

Commit 5ac800f

Browse files
authored
Update Day_11.md
1 parent acd18a4 commit 5ac800f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Status/Day_11.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,32 @@ else:
113113
print("No")
114114
```
115115
----------------
116+
117+
# Question 41
118+
### Level 1
119+
120+
**Question:**
121+
122+
***Write a program which can map() to make a list whose elements are square of elements in [1,2,3,4,5,6,7,8,9,10].***
123+
124+
----------------------
125+
### Hints: Use map() to generate a list.Use lambda to define anonymous functions.
126+
127+
-------------------
128+
129+
**Main Author's Solution: Python 2**
130+
```
131+
li = [1,2,3,4,5,6,7,8,9,10]
132+
squaredNumbers = map(lambda x: x**2, li)
133+
print squaredNumbers
134+
```
135+
----------------
136+
**My Solution: Python 3**
137+
```
138+
# No different way of code is written as the requirment is specificly mentioned in problem description
139+
140+
li = [1,2,3,4,5,6,7,8,9,10]
141+
squaredNumbers = map(lambda x: x**2, li) # returns map type object data
142+
print(list(squaredNumbers)) # converting the object into list
143+
```
144+
--------------

0 commit comments

Comments
 (0)