Skip to content

Commit 392c0d7

Browse files
authored
Update Day_10.md
1 parent 3e3d8c8 commit 392c0d7

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

Status/Day_10.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,39 @@ def printList():
163163
printList()
164164
```
165165
----------------------
166+
# Question 35
167+
### level 1
168+
169+
**Question:**
170+
171+
***Define a function which can generate a list where the values are square of numbers between 1 and 20 (both included). Then the function needs to print all values except the first 5 elements in the list.***
172+
173+
----------------------
174+
### Hints: Use ** operator to get power of a number.Use range() for loops.Use list.append() to add values into a list.Use [n1:n2] to slice a list
175+
176+
-------------------
177+
**Main Author's Solution: Python 2**
178+
```
179+
def printList():
180+
li=list()
181+
for i in range(1,21):
182+
li.append(i**2)
183+
print li[5:]
184+
185+
printList()
186+
```
187+
----------------
188+
**My Solution: Python 3**
189+
```
190+
def printList():
191+
lst = [i ** 2 for i in range(1, 21)]
192+
for i in range(5,20):
193+
print(lst[i])
194+
195+
printList()
196+
```
197+
198+
---------------------
166199

167200
### Comment
168201
***Problems of this section is very much easy and all of those are of a modification of same type problem which mainly focused on using some commonly used function works with list,dictionary, tupple.In my entire solutions, I havn't tried to solve problems in efficient way.Rather I tried to solve in a different way that I can.This will help a beginner to know how simplest problems can be solved in different ways.***

0 commit comments

Comments
 (0)