Skip to content

Commit fc218ea

Browse files
committed
Added solution for day 11
1 parent 0180900 commit fc218ea

File tree

6 files changed

+50
-0
lines changed

6 files changed

+50
-0
lines changed

solution38.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'''
2+
With a given tuple (1,2,3,4,5,6,7,8,9,10), write a program to print the first half values in one line and the last half values in one line.
3+
'''
4+
5+
tup = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
6+
mid_length = round(len(tup) / 2)
7+
print(tup[0:mid_length])
8+
print(tup[mid_length:])

solution39.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'''
2+
Write a program to generate and print another tuple whose values are even numbers in the given tuple (1,2,3,4,5,6,7,8,9,10).
3+
'''
4+
5+
tup = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
6+
result = tuple(filter(lambda num: (num % 2 == 0), tup))
7+
print(result)

solution40.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'''
2+
Write a program which accepts a string as input to print "Yes" if the string is "yes" or "YES" or "Yes", otherwise print "No".
3+
'''
4+
5+
input_string = input()
6+
7+
if input_string == 'yes' or input_string == 'Yes' or input_string == 'YES':
8+
print("Yes")
9+
else:
10+
print("No")

solution41.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'''
2+
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].
3+
'''
4+
5+
lst = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
6+
7+
8+
# def sqrt(num):
9+
# return num**2
10+
11+
result = list(map(lambda x: x**2, lst))
12+
print(result)

solution42.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'''
2+
Write a program which can map() and filter() to make a list whose elements are square of even number in [1,2,3,4,5,6,7,8,9,10].
3+
'''
4+
5+
lst = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
6+
filtered_lst = filter((lambda x: x % 2 == 0), lst)
7+
result = list(map((lambda x: x**2), filtered_lst))
8+
print(result)

solution43.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'''
2+
Write a program which can filter() to make a list whose elements are even number between 1 and 20 (both included).
3+
'''
4+
5+
print(list(filter((lambda x: x % 2 == 0), range(1, 21))))

0 commit comments

Comments
 (0)