Skip to content

Commit 1239d14

Browse files
authored
Update Day_10.md
1 parent b6a4481 commit 1239d14

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Status/Day_10.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,33 @@ printDict()
6464

6565
# Question 33
6666
### level 1
67+
68+
**Question:**
69+
70+
***Define a function which can generate and print a list where the values are square of numbers between 1 and 20 (both included).***
71+
72+
----------------------
73+
### Hints:
74+
#### Use ** operator to get power of a number.Use range() for loops.Use list.append() to add values into a list.
75+
76+
-------------------
77+
**Main Author's Solution: Python 2**
78+
```
79+
def printList():
80+
li=list()
81+
for i in range(1,21):
82+
li.append(i**2)
83+
print li
84+
85+
printList()
86+
```
87+
----------------
88+
**My Solution: Python 3**
89+
```
90+
def printDict():
91+
lst = [i ** 2 for i in range(1, 21)]
92+
print(lst)
93+
94+
printDict()
95+
```
96+
-------------------

0 commit comments

Comments
 (0)