You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Write a program that accepts a sequence of whitespace separated words as input and prints the words after removing all duplicate words and sorting them alphanumerically.
4
+
5
+
# Suppose the following input is supplied to the program:
6
+
7
+
# hello world and practice makes perfect and hello world again
8
+
9
+
# Then, the output should be:
10
+
11
+
# again and hello makes perfect practice world
12
+
13
+
word=sorted(list(set(input().split()))) # input string splits -> converting into set() to store unique
14
+
# element -> converting into list to be able to apply sort
# Write a program which accepts a sequence of comma separated 4 digit binary numbers as its input and then check whether they are divisible by 5 or not. The numbers that are divisible by 5 are to be printed in a comma separated sequence.
4
+
5
+
# Example:
6
+
7
+
# 0100,0011,1010,1001
8
+
9
+
# Then the output should be:
10
+
11
+
# 1010
12
+
13
+
# Function to convert Binary number
14
+
# to Decimal number
15
+
16
+
data=input().split(',')
17
+
data=list(filter(lambdai:int(i,2)%5==0,data)) # lambda is an operator that helps to write function of one line
0 commit comments