Skip to content

Commit e05d02f

Browse files
authored
Update Day_10.md
1 parent 71e9b93 commit e05d02f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Status/Day_10.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@
55

66
***Define a function which can print a dictionary where the keys are numbers between 1 and 20 (both included) and the values are square of keys.***
77

8-
98
----------------------
10-
### Hints:
11-
####
12-
Use dict[key]=value pattern to put entry into a dictionary.
13-
Use ** operator to get power of a number.
14-
Use range() for loops.
15-
9+
### Hints: Use dict[key]=value pattern to put entry into a dictionary.Use ** operator to get power of a number.Use range() for loops.
1610
-------------------
17-
Solution
11+
**Main Author's Solution: Python 2
12+
```
1813
def printDict():
1914
d=dict()
2015
for i in range(1,21):
@@ -26,4 +21,9 @@ printDict()
2621
----------------
2722
**My Solution: Python 3**
2823
```
24+
def printDict():
25+
dict={i:i**2 for i in range(1,21)} # Using comprehension method and
26+
print(dict)
27+
28+
printDict()
2929
```

0 commit comments

Comments
 (0)