Q. Write definition of a method ZeroEnding(SCORES) to add all those values in the list of SCORES, which are ending with zero (0) and display the sum.


For example,
If the SCORES contain [200,456,300,100,234,678]
The sum should be displayed as 600

Answer =


def ZeroEnding (SCORES) :
    SZero = 0
    for i in SCORES :
        if i % 10 == 0:
            SZero += i
    print ("sum of numbers ending with zero : ", SZero)


Output :-

 >>> ZeroEnding ([10, 20, 30, 40])
sum of numbers ending with zero :  100
>>>

>>> ZeroEnding ([100, 25, 51, 20, 35, 50, 60, 120, 300, 555, 450, 999, 100])
sum of numbers ending with zero :  1200
>>>

2 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. waste fellow this code is not working

    ReplyDelete
    Replies
    1. yes not working stupid website

      Delete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post