2014-02-21 52 views
0
initial_bal = int(input("enter initial balance")) 
withdraw_money = int(input("enter balance to withdraw")) 
f = 0 
if withdraw_money % 5 == 0 : 
    if (withdraw_money + 0.5) <= initial_bal: 
     f = 1 

if f == 1: 
    account_bal = initial_bal - (withdraw_money + 0.5) 
    print ("remaining balance : " , account_bal) 
else : 
    print(initial_bal) 

當我上面所寫的代碼codechef提交的,則投擲運行時錯誤(NZEC)。它在我的機器上工作得很好。 任何人都可以告訴,我的代碼中的錯誤在哪裏?蟒運行時間錯誤(NZEC)

+1

這是Python的3.x的代碼,你從列表中選擇Python 3中的實際代碼? – thefourtheye

+0

https://github.com/SavinaRoja/PyUserInput或https://fedorahosted.org/dogtail/將會更喜歡。 – Torxed

+0

不是實際...... – user3157110

回答

1

首先,您不必像打印東西那樣打印「輸入初始餘額」。你只需要打印測試用例中給出的內容。只是打印什麼在測試情況作了說明..其它...
這是蟒蛇

class Main: 

    s=raw_input() 
    s=s.split(" ") 
    x=float(s[0]) 
    y=float(s[1]) 
    if(x%5==0 and x+0.50<=y): 
     p=y-x-0.50 
     print("%.2f"%p) 
    else: 
     print("%.2f"%y)