File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 1+ # Write a program which accepts a sequence of comma separated 4 digit binary
2+ # numbers as its input and then check whether they are divisible by 5 or
3+ # not. The numbers that are divisible by 5 are to be printed in a comma
4+ # separated sequence.
5+ # Example:
6+ # 0100,0011,1010,1001
7+ # Then the output should be:
8+ # 1010
9+ # Notes: Assume the data is input by console.
10+ baseStr = input ('Enter binary no.: ' )
11+ ans = []
12+ numSeq = [int (i ,2 ) for i in baseStr .split (',' )]
13+
14+ for i in numSeq :
15+ if i % 5 == 0 :
16+ ans .append (bin (i ).replace ('0b' ,'' ))
17+
18+ print (* ans , sep = ',' )
Original file line number Diff line number Diff line change 2222 Q = math .sqrt ((2 * C * Seq )/ H )
2323 numList [i ] = int (Q )
2424 i += 1
25- print (numList )
25+ print (* numList , sep = ',' )
2626
2727# Solution
2828# import math
You can’t perform that action at this time.
0 commit comments