Incomplete format error - Python

EDIT: never mind I figured out the problem~ it was an extra ":" inside the __main__... -.-!!
But new problem! If I run the program and input the answers, it returns an error:
Traceback (most recent call last):
File "<string>", line 1, in <string>
ValueError: incomplete format
Does anyone know what this means?
Original question
Hi everyone, I'm a total beginner to Python, currently studying it in university.
I'm almost done this assignment that asks me to create a program that accepts input from user on a few questions, then based on the answers calculate his or her total tax credit.
Here is the full code:
(Is it just me or is there no tags on a programming forum...???)
#Tax credit calculator functions
def dependant_amount(d_net_income):
    '''Return the deductible amount to be entered on line 5816 of the Ontario
    Tax form, based on float d_net_income, the dependant's net income.'''
    line_3 = max(0, 8108.00 - d_net_income)
    return min(7371.0, line_3)
def medical_amount(d_net_income, med_expenses):
    '''Return the amount to be entered on line 5872: "Allowable medical
    expenses", of the Ontario Tax Form, based on float d_net_income,
    representing the taxpayer's dependant's net income, and float med_expenses,
    representing his or her medical expenses.'''
    line_2 = min(d_net_income * 0.03, 1965.0)
    return medical_expenses - line_2
def age_amount(net_income):
    '''Return the amount to be entered on line 5808: "Age amount", of the
    Ontario Tax Form, based on float net_income, the taxpayer's net income. This
    credit applies only to persons born in 1943 or earlier.'''
    line_4 = max(0, net_income - 31554.0)
    line_6 = line_4 * 0.15
    age = max(0, 4239.0 - line_6)
    return age
def infirm(d_net_income):
    '''Return the amount to be entered on line 5820: "Amount for infirm
    dependants age 18 or older", of the Ontario Tax Form, based on float
    d_net_income, representing the taxpayer's dependant's net income.'''
    if 9908.0 - d_net_income > 4091.0:
        line_3 = 4091.0
        line_3 = max(0, 9908.0 - d_net_income)
    return line_3
def political_amount(contribution):
    '''Return the amount to be entered on line 24: "Ontario political
    contribution tax credit", of the Ontario Tax Form, based on float
    contributions, representing the taxpayer's political contributions.'''
    if contribution <= 336.0:
        line_7 = contribution * 0.75
    elif 336.0 < contribution <= 1120.0:
        line_7 = ((contribution - 336.0) * 0.5) + 252.0
    elif 1120.0 < contribution <= 2548.0:
        line_7 = ((contribution - 1120.0) * 0.3333) + 644.0
        line_7 = 1120.0
    return line_7
#Tax credit calculator
if __name__ == "__main__:":
    #User-defined values of parameters of the functions defined earlier
    net_income = float(raw_input("Please enter your net income: "))
    d_net_income = float(raw_input("Please enter your dependant's net"
                                   " income: "))
    med_expenses = float(raw_input("Please enter your dependant's medical"
                                   " expenses: "))
    infirmity = raw_input("Is your dependant infirm (please enter 'yes' or"
                          "'no'): ")
    year_of_birth = float(raw_input("Please enter the year you were born (all"
                                    " four digits): "))
    contribution = float(raw_input("Please enter the amount of your political"
                                   " contributions: "))
    if infirmity == "yes":
        line_3 = True     
        line_3 = False
    if year_of_birth <= 1943:
        age = True
        age = False
    total_tax_credit = medical_amount(d_net_income, med_expenses) + \
                     age_amount(net_income) + infirm(d_net_income) + \
    print "Your Ontario Tax Credit is: $%" %total_tax_credit
*In Python Shell after I click RUN*
Type "help", "copyright", "credits" or "license" for more information.
Basically the user is asked 6 questions, and each answer will have an effect on the variables operated in the functions defined in the first segment of the program. When I execute the program the questions written won't appear in Python Shell though...
Thanks in advance for help!
Edited by: user12005824 on 2009-10-6 下午3:57
Edited by: user12005824 on 2009-10-6 下午3:59                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    

Do you realize this has nothing to do with oracle? You should subscribe to python list [1] next time for this kind of questions (and don't tell it's homework or else nobody will help you).
Anyway, I think you're missing the output format [2]:
print "Your Ontario Tax Credit is: $%f" % (total_tax_credit)


Variable1 = #next(cogs,1,#currmbr(time):wk53,wk1:wk53)

Hi,Could anyone please brief me on what this function actually does? Variable1 = #next(cogs,1,#currmbr(time):wk53,wk1:wk53) Thanks
That's a pretty weird construct (I wouldn't have expected the two separate ranges to be a valid range / xrange list as required by #NEXT, but I guess if it's running it must be). Anyway, it should be returning the value of COGS for the week after the current one. If the dimension named 'Time' is actually tagged as time and Weeks are the level 0 members, then #NEXT(COGS) would do exactly the same thing.
It will return the next Cogs value within the following range (#currmbr(time):wk53); for ex say if your your currmbr on time is wk50, you will get the value for wk51. Thanks,
Exactly, that was my question as well. This is the script used by one of our new clients. Wondering why do they have a fourth parameter for #Next (wk1:wk53). Apparently its running (haven't personally tried it, no access yet).
Here is the whole context: It loops 53 times max (total number of weeks) or till it meets the condition (IF (VAR_CUMSLS >= VAR_BI)). Hence the code is cumbersome. Looking for ways to minimize/optimize it. Any suggestions?  IF (VAR_CUMSLS >= VAR_BI)  VAR_POS = 0;  ELSE  VAR_SALES = #NEXT(COGS, 1, #CURRMBR(Time):WK53, WK1:WK53);  VAR_PREV_CUMSLS = VAR_CUMSLS; VAR_CUMSLS = VAR_CUMSLS + VAR_SALES;  IF (VAR_CUMSLS >= VAR_BI)  VAR_POS = 1;  ELSE  VAR_SALES = #NEXT(COGS, 2, #CURRMBR(Time):WK53, WK1:WK53);   VAR_PREV_CUMSLS = VAR_CUMSLS; VAR_CUMSLS = VAR_CUMSLS + VAR_SALES;  IF (VAR_CUMSLS >= VAR_BI)  VAR_POS = 2;  ELSE  VAR_SALES = #NEXT(COGS, 3, #CURRMBR(Time):WK53, WK1:WK53);   VAR_PREV_CUMSLS = VAR_CUMSLS; VAR_CUMSLS = VAR_CUMSLS + VAR_SALES;  IF (VAR_CUMSLS >= VAR_BI)  VAR_POS = 3;
Could you describe the objective in English rather than in code (especially since it seems to be pretty 'odd' code - not the best starting point for understanding the requirement)?
Sure Tim. This script is to calculate an account (say account X) .  So this script will iterate  through a maximum of 53 weeks till the cumulative sales is greater or equal to beginning Inventory. Hope this helps. VAR VAR_BI, VAR_CUMSLS, VAR_PREV_CUMSLS, VAR_SALES, VAR_POS, MAX_PERIODS = 53;FIX(#IDESC("MerchPlan",0), #IDESC("TestProd", 0), AllTypes, CY, GPlan, WK1:&lastplanwk)  Account X(  /* If Beginning Inventory > 0, Calculate Account X*/  VAR_BI = Account Y;  IF (VAR_BI > 0)  VAR_SALES = COGS;  VAR_CUMSLS = VAR_SALES;  VAR_PREV_CUMSLS = 0;   /*  /* Starting From The Current Week, Determine The Week In Which The Accumulated   /* Sales Exceeds The Current Week's Beginning Inventory   */  IF (VAR_CUMSLS >= VAR_BI)  VAR_POS = 0;  ELSE  VAR_SALES = #NEXT(COGS, 1, #CURRMBR(Time):WK53, WK1:WK53);  VAR_PREV_CUMSLS = VAR_CUMSLS; VAR_CUMSLS = VAR_CUMSLS + VAR_SALES;  IF (VAR_CUMSLS >= VAR_BI)  VAR_POS = 1;  ELSE  VAR_SALES = #NEXT(COGS, 2, #CURRMBR(Time):WK53, WK1:WK53);   VAR_PREV_CUMSLS = VAR_CUMSLS; VAR_CUMSLS = VAR_CUMSLS + VAR_SALES;  IF (VAR_CUMSLS >= VAR_BI)  VAR_POS = 2; etc..etc..etc..

XMLTABLE where node names become columns

I hope someone can help me with this XMLTABLE question.
I have XML data stored in a column of a table. I want to map the contents of the XML into relational rows and columns. My request is rather simple: I would like each name of node in the XML to become a column, the contents of the column equal to the name of the node.
Here is what rows in my table look like:
ID      XML_CONTENT                            
------  ----------------------------------------
832-Q   <LevelOne>                 
562-B   <LevelOne>
        </LevelOne>And what I would like as output is something like this:
ID     L2           L3              H1       H2
-----  --------     ------------    -------  --------
832-Q  LevelTwo_A   LevelThree_1    3.4      5.6
832-Q  LevelTwo_A   LevelThree_2    1.2      8.2
832-Q  LevelTwo_A   LevelThree_3    5.2      5.22
832-Q  LevelTwo_A   LevelThree_4    3.9      1.9
562-B  LevelTwo_B   LevelThree_1    32.4     5.5
562-B  LevelTwo_B   LevelThree_4    10.2     8.1One way to put this is that it is really the H1 and H2 elements I'm interested in. Each node name in the path leading up to that I want to become columns in my output. Note: My H1 and H2 elements are always at exactly the depth as indicated in the example. I'm not interested in the very first node name ('LevelOne') of XML_CONTENT, simply because in my case it is always similar among the rows in my table.
I've tried numerous forms of XMLTABLE but just cannot seem to get this right. At the same time I think my request is rather simple so I'm a bit embarrassed that I cannot figure this one out. Anyone can help ?
Edited by: user491370 on Apr 11, 2010 9:51 PM 
Your sample had to be corrected a little (e.g. <h1>3.4</h2>) but here goes :
-- < Data sample ----------------------------------------------------
SELECT '832-Q' id, xmltype(
) doc
FROM dual
SELECT '562-B', xmltype(
FROM dual
-- ---------------------------------------------------- Data sample >
FROM t, xmltable(
'for $i in $d//*[h1|h2]
  return element row { attribute L3 { local-name($i) },
                       attribute L2 { local-name($i/..) },
                       $i/h2 }'
  passing t.doc as "d"
   l2 varchar2(30) path '#L2',
   l3 varchar2(30) path '#L3',
   h1 varchar2(30) path 'h1',
   h2 varchar2(30) path 'h2'
) x;The key here is to select each parent of "h1" and "h2", then we can construct each "row" (function local-name() is used to retrieve the node name). 
Excellent answer !
Thank you so much.
Unfortunately your suggestion is sufficiently advanced that Oracle cannot use its parsing routines build in C but has to resort to Java. In short Java must be installed on the database in order for this to work.
Specifically I get the "identifier 'SYS.DBMS_XQUERYINT' must be declared" error which is pretty well documented in PLS-00201: identifier 'SYS.DBMS_XQUERYINT' must be declared . (read the answers from user 'mdrake' which kind of says it all).
But this is just a minor setback. Your answer was exactly what I was looking for.
Edited by: MrMonza on Apr 15, 2010 10:35 PM

HELP - Nested Case Question (Multiple Rows)

OK, Now that the syntax has been corrected with the help of "Chanchal Wankhade" (Thank you very much!), I have an entirely new issue. I am sure this issue has to do with my case statement logic. I am getting multiple rows, when I am only looking for one. Here is my code:
        THEN 'COMING UP'
        ELSE 'No'
        THEN 'COMING UP'
        ELSE 'No'
  END "Needs Physical?"
ON AE.EMP_ID         = EC.EMP_ID
Needs Physical?
Row 2 No
However, only one of these rows should be the output, which is "No". How do you get a nested case statement to evaluate to one result, instead of multiple? I'm quite sure it is in the logic. To spell it out, this is what I am trying to accomplish with the above code:
If the "EP.PHYSICAL_DATE" is null, then use these sets of formula's to evalute the output, BUT if the "EP.PHYSICAL_DATE" is not null, then use these set's of formula's to evaluate the output.
As it stands now, it appears as if my nested case statement is doing exactly what I told it to do, which is to evaluate both conditions, and output both.
Any help would be appreciated. Thanks.
Edited by: AquaNX4 on Mar 26, 2013 6:30 AM

Invert sign on import with script

Dear Guruz, Both FDMEE and new scripting language Jython are beautiful. Now please help me please with the following : This script works fine :
def separation(strfield,strrec):
    if strfield == 0:
        return strrec.split(";")[8]
        x = strfield
        return x
 This script, where I want to invert x value, does not work fine! Why and how to handle this issue?
def separation(strfield,strrec):
    if strfield == 0:
        return strrec.split(";")[8]
        x = strfield * -1
        return x
 Many thanks.
What is the value of strField are you certain it is a string that can be implicitly converted to a number? Your first code block doen't care whether strField is a string or a numeric value but your second code block requires a numeric value to successfully perform the arithmetic calculation x = strFiled * 1
HI,let me try to help showing you some examples.Firstly, think that FDMEE is passing string parameters to the import scriptIn this example you can see that what you basically need is to convert into float your strfield and 9th field of the record.In that way, you would be able to reverse sign.Note that x = x * -1 is also valid although the jythonic way would be x *= -1But what would happen if any of strfield or 9th field cannot be converted to float?As you can see it would fail due to ValueError exception.In Jython when type conversions are needed like float() using try/except is recommended.In the following example, if any of the two fields are not number the record will be skipped during the import:I hope that helps. Regards
Thank you Francisco for your help. You provided great guidance regarding my issue which is now solved! I though that typing were manfatory with Jython. Thanks again. SebRoux

FDM TB tolerance limit

Hello Experts, We are using FDM and wrote a custom script as below to set import tolerance limit of 250 <entity currency>.Based on this script ,if source trail balance is out of balance by more than 250 then FDM import fails and working as expected but now we got an additional requirement of loading head count into hfm using fdm for couple of entites.As headcount will not have Dr=Cr, their source trial balance is becoming out balance by more than set tolerance limit there a way where we can skip this headcount a/c from considering into tolerance limit while importing the file? Sub AftValidate(strLoc, strCat, strPer, lngProcState)'------------------------------------------------------------------'Oracle Hyperion FDM EVENT Script:'''Purpose: Trial balance validation script''------------------------------------------------------------------Set objxx = CreateObject ("scripting.filesystemObject").opentextfile("D:\Oracle\FDMdata\ArcherFDM\fdm.log",8,True)objxx.writeline ("hhahhahah")  Dim strSQLDim strBaseSQLDim rsDim lngCheckAccountAmountDim strCheckAccountDim intToleranceDim strMessage'*******************************************'This script is valid for Actual Scenario '******************************************If strCat = "ACT" ThenIf 1 = 1 Thenobjxx.writeline ("entered first loop")    'The name of the logic account whose value to check    strCheckAccount = "CHECKACCOUNT"        'The tolerance for the check account    intTolerance = 250        'This is the message the user will see            '======================================================================================    ' YOU DO NOT NEED TO CHANGE ANYTHING AFTER THIS LINE    '======================================================================================        'Build up a basic SQL string    strBaseSQL = "SELECT sum(AMOUNT)as AMOUNT FROM TDATASEG#SEGNO# WHERE PERIODKEY = TO_DATE('#PERIOD#','mm/dd/yyyy')"    objxx.writeline (strBaseSQL)    strBaseSQL = strBaseSQL & "AND PARTITIONKEY = #PARTKEY# AND CATKEY = #CATKEY# "        'Substitute the relevant keys for this POV    strBaseSQL = Replace(strBaseSQL, "#PERIOD#", RES.PdtePerKey)    strBaseSQL = Replace(strBaseSQL, "#PARTKEY#", RES.PlngLocKey)    strBaseSQL = Replace(strBaseSQL, "#SEGNO#", RES.PlngSegKey)    strBaseSQL = Replace(strBaseSQL, "#CATKEY#", RES.PlngCatKey)    'Replace account     strSQL = Replace(strBaseSQL, "#ACC#", strCheckAccount)     objxx.writeline (strSQL)    'Create a recordset    Set rs = DW.DataAccess.farsSnap(strSQL)     objxx.writeline ("query executed")        'Get the value of the account    lngCheckAccountAmount = 0     objxx.writeline (Abs(CDbl(lngCheckAccountAmount)))    If Not rs.BOF And Not rs.EOF Then        lngCheckAccountAmount = rs.Fields("Amount").Value    End If        Set rs = Nothing        'Here's the check. It must be within tolerance.    objxx.writeline (Abs(CDbl(lngCheckAccountAmount)))    objxx.writeline (intTolerance)       If Abs(CDbl(lngCheckAccountAmount)) > intTolerance Then                                  objxx.writeline ("entered loop")                  API.MaintenanceMgr.mProcessLog API.POVMgr.PPOVLocation, API.POVMgr.PPOVCategory, API.POVMgr.PPOVPeriod, 2, False, "AftValidate error", Now()        'Error so update the process state        'API.MaintenanceMgr.mProcessLog strLoc, strCat, strPer, 1, False, "Import Errors", Now()       ' API.MaintenanceMgr.mProcessLog RES.PstrLoc, RES.PstrCat, RES.PstrPer, 1, False, "Import Errors", Now()        ' Last event - Cancel is not enabled so ignore it.        'RES.PcolScriptInfo.Item("ScriptInfo").ColFlds.item("Cancel").varValue = RES.FDMTrue        ' Set up a message for the user. 2 = new window, 6 = InfoBar        RES.PlngActionType = 2        ' Message for the user        strMessage = "Validation error: will not proceed to next step because SET TOLERANCE is [" & intTolerance & "]and TB IMBALANCE is currently ["&Abs(CDbl(lngCheckAccountAmount))&"]"        RES.PstrActionValue = strMessage    End If    End IfEnd If End Sub
Just create a logic account that doesn't contain headcount