473,411 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Help with a sytax error please

I'm getting a syntax error at the first if statement in my commission statement, indicated with carat. Thank you for your time in advance. It's probably something simple i'm still pretty new at this.
Expand|Select|Wrap|Line Numbers
  1. def sales():
  2.     amount = int(input('Enter the monthly sales:'))
  3.     return amount
  4.  
  5. def advance_pay():
  6.     advance = int(input('Enter the  amount of advance pay, or enter 0 if no advance pay was given'))
  7.     return advance
  8.  
  9. def commission():
  10.     comm  =
  11.     if amount() < 10000:
  12.     ^this is where i'm getting the error.
  13.         com = .10
  14.     if 10000<= amount() <= 14999.99:
  15.         com = .12
  16.     if 15000 <= amount() <=17999.99:
  17.         com = .14
  18.     if 18000 <= amount() <= 21999.99:
  19.         com = .16
  20.     else:
  21.         com = .18)
  22.     return comm
  23.  
  24. def pay_out():
  25.     pay = amount*com - advance
  26.     return pay
  27.  
  28.  
  29. def main():
  30.     again = 'yes'
  31.     while again == 'yes':
  32.  
  33.         amount()
  34.         advance()
  35.         comm()
  36.         pay()
  37.  
  38.         print ('The pay is:$', pay)
  39.         if pay < 0:
  40.              print ('The salesperson must reimburse the company.')
  41.         again = input('Do you want to calculate another commission (yes/no):')
  42. main()
Feb 23 '10 #1
1 987
bvdet
2,851 Expert Mod 2GB
You cannot make a statement in the manner you are trying. Use an if/elif block instead of a series of if statements. Be aware of function scope with respect to variables. Use function arguments and return values to make assignments in other functions. Example:
Expand|Select|Wrap|Line Numbers
  1. >>> def a(arg):
  2. ...     b = arg*10
  3. ...     return b
  4. ... 
  5. >>> z = 8
  6. >>> zz = a(z)
  7. >>> zz
  8. 80
  9. >>> def b(arg):
  10. ...     return a(arg)*10
  11. ... 
  12. >>> print b(z)
  13. 800
  14. >>> 
I reworked your function commission().
Expand|Select|Wrap|Line Numbers
  1. def commission():
  2.     amount = sales()
  3.     if amount < 10000:
  4.         com = .10
  5.     elif 10000<= amount <= 14999.99:
  6.         com = .12
  7.     elif 15000 <= amount <=17999.99:
  8.         com = .14
  9.     elif 18000 <= amount <= 21999.99:
  10.         com = .16
  11.     else:
  12.         com = .18
  13.     return com
  14.  
  15. print commission()
Feb 23 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: ColdCanuck | last post by:
Help! I'm trying to understand the new ANSI join syntax (after many years of coding using the old style). I am now working with an application that only understands ANSI syntax so I am...
12
by: serge calderara | last post by:
Dear all, I have a function that I need to run in a thread due to the fact that it can takes long time to execute according to the amount of data to collect. This function is also populating a...
1
by: Robert | last post by:
I have two tables (classes and students). Right now, I'm generating a report in asp that shows a list of classes, the enrollment for each class, and how many seats are available (see query below)....
2
by: Gobi | last post by:
Hello, I was wondering how to modify the Do.cmd wherecondition statement to filter not only for RATTY name but also for the "LAST" field that contain a "^" carrot in front of them...With the...
3
by: Kranman | last post by:
Hi All, Love this site, have gotten a lot from it. This is my first time posting though, so forgive me for any errors. I have an Access 2000 db where I have a main form of Contractors and on...
5
by: serge calderara | last post by:
Dear all, I am new in asp.net and prepare myself for exam I still have dificulties to understand the difference between server control and HTML control. Okey things whcih are clear are the fact...
3
by: Arthur Dzhelali | last post by:
I am trying dynamically create controls and add them to the form on the Separate thread. I know that I have to use delegate in order to update preexisting controls on the form, but when I ma...
4
by: ItsMe | last post by:
Hi Guyz, I'm unable to understand this (AddressOf) error??? In VB6 I have two functions: ---------------------------- Public Function ImageFirstImageCallback(ByVal hWnd As Integer, ByVal...
9
by: What-A-Tool | last post by:
There are several differences in "switch", and VB's "Select Case"(which is what I'm used to) that I can't quite figure. Could someone please point out what is wrong with the following code - in...
20
lagomorphmom
by: lagomorphmom | last post by:
Hi, I'm a microbiologist but also dabble with many of the computer needs of our little lab. My latest project involves an unfinished database (Access 2000 format, I'm running 2003 on XP PC)...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.