Skip to content

Commit 0180900

Browse files
committed
Added solution for day10
1 parent 6a33466 commit 0180900

File tree

7 files changed

+74
-0
lines changed

7 files changed

+74
-0
lines changed

solution31.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'''
2+
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.
3+
'''
4+
5+
6+
def printDictionary():
7+
8+
my_dict = dict()
9+
for number in range(1, 21):
10+
my_dict[number] = number**2
11+
print(my_dict)
12+
13+
printDictionary()

solution32.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'''
2+
Define a function which can generate a dictionary where the keys are numbers between 1 and 20 (both included) and the values are square of keys. The function should just print the keys only.
3+
4+
'''
5+
6+
7+
def printDictKeys():
8+
my_dict = {number: number**2 for number in range(1, 21)}
9+
print(my_dict.keys())
10+
11+
printDictKeys()

solution33.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'''
2+
Define a function which can generate and print a list where the values are square of numbers between 1 and 20 (both included).
3+
'''
4+
5+
6+
def printList():
7+
my_list = [number**2 for number in range(1, 21)]
8+
print(my_list)
9+
10+
printList()

solution34.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'''
2+
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 the first 5 elements in the list.
3+
'''
4+
5+
6+
def printFirstFiveElementOfList():
7+
my_list = [number**2 for number in range(1, 21)]
8+
print(my_list[:5])
9+
10+
printFirstFiveElementOfList()

solution35.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'''
2+
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 the last 5 elements in the list.
3+
'''
4+
5+
6+
def printLastFiveElementOfList():
7+
my_list = [number**2 for number in range(1, 21)]
8+
print(my_list[-5:])
9+
10+
printLastFiveElementOfList()

solution36.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'''
2+
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.
3+
'''
4+
5+
6+
def skipFirstFiveElementOfList():
7+
my_list = [number**2 for number in range(1, 21)]
8+
print(my_list[5:])
9+
10+
skipFirstFiveElementOfList()

solution37.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'''
2+
Define a function which can generate and print a tuple where the value are square of numbers between 1 and 20 (both included).
3+
'''
4+
5+
6+
def printTuple():
7+
my_list = [number**2 for number in range(1, 21)]
8+
print(tuple(my_list))
9+
10+
printTuple()

0 commit comments

Comments
 (0)