Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 29th, 2012  |  syntax: None  |  size: 2.95 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. I'm getting a SyntaxError: (unicode error) 'unicodeescape' codec
  2. #=====================================================================
  3. # Program:      Calculating Sales
  4. # Programmer:   Viet-Anh Tran
  5. # Date:         2-14-2012
  6. #               July 1, 2011 - Revised for Python 3
  7. # Abstract:     This program processes highest sales, lowest sales,
  8. #               and averages the total numnber of sales. Each
  9. #               salesperson will be asked enter the amount they sold
  10. #               and the price of each sale.
  11. #=====================================================================
  12.  
  13. def main():
  14.     #create variable to control loop
  15.     keep_going = 'y'
  16.     #process each salperson's sales
  17.     while keep_going == 'y' or keep_going == 'Y':
  18.         #use a function to process sales
  19.         show_sales()
  20.         keep_going = input("would you like to calculate another salesperson's" +
  21.         "sales? (enter y or Y as yes to continue) ")
  22. #define show_sales
  23. def show_sales():
  24.     #ask for name of salesperson
  25.     name = input("What is the salesperson's name? ")
  26.     #ask for first sales amount
  27.     print('Enter', name, "'s first sale amount: ")
  28.     first_sale = float(input())
  29.     #when assigning a value for first sale make sure its bewtween 1-25000
  30.     while first_sale < 1 or first_sale > 25000:
  31.         #prompt error message if it does not meet within range
  32.         print('ERROR: First sale amount must fall in the range of $1-$25,000.')
  33.         #ask user again for CORRECT amount
  34.         print('Please enter', name, "'s correct first sale amount:")
  35.         first_sale = float(input())
  36.     #assign all total highest and lowest sales to first sale
  37.     total_sale = first_sale
  38.     highest_sale = first_sale
  39.     lowest_sale = first_sale
  40.     #ask for the total number of sales
  41.     print('Are there any more sales? If so, type in the total number of sales:')
  42.     number_sales = int(input())
  43.     #create a loop
  44.     for sale in range(2, number_sales + 1):
  45.         print('What is', name, "'s next sales amount?")
  46.         sales_amount = float(input())
  47.         #again make sure that it is within range and ask the correct amount again
  48.         while sales_amount < 1 or first_sale > 25000:
  49.             print('ERROR: Sale amount must fall in the range of $1-$25,000.')
  50.         print('Please enter', name, "'s correct sale amount:")
  51.         sales_amount = float(input())
  52.         #accumulate the total sales
  53.         total_sales += sales_amount
  54.         #this assigns the lowest and highest value to the correct variable
  55.         if sales_amount > highest_sale:
  56.             highest_sale = sales_amount
  57.         if sales_amount < lowest_sale:
  58.             lowest_sale = sales_amount
  59.     #calculate average and print highest, lowest, and average
  60.     average_sales = total_sales / number_sales
  61.     print(name, "'s highest sale: $", format(highest_sale, ',.2f'), sep='')
  62.     print(name, "'s lowest sale: $", format(lowest_sale, ',.2f'), sep='')
  63.     print(name, "'s sale on average: $", format(average_sale, ',.2f'), sep='')