vendredi 26 juin 2020

ATM code chef question if - else condition problem in python

a, b = input().split()
c = int(a)
d = float(b)
e = format(d, ".2f")

if c % 5 == 0:
    f = d - c - 0.50
    print(format(f, ".2f"))
elif c % 5 != 0:
    print(e)
elif c > d:
    print(e)
else:
    print(e)
  1. here if you take input of 30 120.00 then 1st if condition will do it
  2. 2nd elif will see if the first int input is not multiple of 5 (which is 30 in above 1st point) then give out put of balance which is 120.00
  3. but i am having issue with 3rd condition where i am not trying to do if inputted amount of withdrawal is larger then balance then we should show balance as output (ex: 300 120.00 output 120.00) https://www.codechef.com/problems/HS08TEST
  4. above is link to question which i am trying to solve just refer it also once.

Aucun commentaire:

Enregistrer un commentaire