Summer training at Goeduhub Technologies-Jaipur

Online Instructor-Led Live Training Courses/Workshops details || Claim for online workshop's certificate

0 like 0 dislike
10 views
in Examples, Exercises and Projects by Goeduhub's Expert (7.3k points)

program which accepts a sequence of comma separated 4 digit binary numbers as its input and print the numbers that are divisible by 5 in a comma separated sequence.

inputs-

1001 0101 0111 1010 output-

number divisble by 5 ['0101', '1010']

1 Answer

0 like 0 dislike
by Goeduhub's Expert (7.3k points)
 
Best answer
l=[]

def bini(a):

    temp=0

    k =3

    for i in a:

        if(i == '1'):

            temp = temp + pow(2,k)

            k=k-1

        else:

            k=k-1

            continue      

    if(temp%5==0):

        l.append(a)      

for i in range(0,4):  

    bini(input())

print("number divisble by 5 : ",l)

Related questions

 Know About Popular Colleges/Universities  List of IITsList of NITs | RTU-Kota | BTU-Bikaner | Manipal University-Jaipur | JECRC University | Amity University Jaipur | BIT Mesra-Jaipur | MODY UNIVERSITY | LNMIIT-Jaipur | JK Lakshmipat | Banasthali Vidyapith | POORNIMA University
 Exams:   List of Exams After Graduation | List of Engineering Entrance Examinations (UG/PG) | JEE Main | JEE Advanced | GATE | IES | ISROList of PSUs
Placements:  List of companies | Logical Reasoning Questions | Quantitative Aptitude Questions | General English Questions | Technical-MCQ and Interview Questions
 Download Previous Year Papers For:  GATE | IES | RAJASTHAN TECHNICAL UNIVERSITY (RTU-Kota)RPSC Technical Exams | ISRO
 Online Free Training:  Artificial Intelligence(AI) & Machine Learning(ML)Python Programming | Internet of Things-IoT | OpenCV (Open Source Computer Vision Library) | LINUX | Big Data : Hadoop | 
 Goeduhub
About Us | Contact Us   Social::   |  | 
...