python - TypeError: int() argument must be a string or a number, not 'tuple' -


i'm trying figure out error homework assignment i'm working on. it's suppose payroll program calculates pay , overtime pay, overtime defined amount of hours on 40.


my error:

traceback (most recent call last):   file "c:\python33\assignment6.py", line 79, in <module>     main()   file "c:\python33\assignment6.py", line 18, in main     original_pay = calculate_pay(original_hours, original_rate)   file "c:\python33\assignment6.py", line 52, in calculate_pay     original_hours = int(original_hours) typeerror: int() argument must string or number, not 'tuple' 

my code:

overtime_rate_constant = .5  overtime_limit = 40  overtime_hours = 0  def main ():     greet()     original_hours = get_hours()     original_rate = get_rate()     original_pay = calculate_pay(original_hours, original_rate)     totalpay = overtime_pay + original_pay     print_data(original_rate, overtime_hours, original_hours, calculate_overtime_hours, original_pay, totalpay)  def get_hours ():          original_hours = int(input("please enter hours worked (8-86): "))     print()      while original_hours < 8 or original_hours > 86:         print("you must enter between 8 - 86 hours.")         print()         original_hours = int(input("please try again: "))         print()       original_hours = int(original_hours)     original_hours in range (41, 86):         overtime_hours = original_hours - overtime_limit         return original_hours, overtime_hours         return original_hours    def get_rate ():      original_rate = int(input("please enter hourly rate: "))     print()     while original_rate < 7 or original_rate > 50:         print("you must enter pay rate between 7 - 50 dollars")         print()         rate = int(input("please try again: "))         print()         return original_rate     return original_rate def calculate_pay (original_hours, original_rate):      original_hours = int(original_hours)     original_rate = int(original_rate)      original_pay = original_hours * original_rate     overtime_pay = original_hours * original_hours + overtime_hours * .5      return overtime_pay, original_pay  def print_data (original_rate, overtime_hours, original_hours, overtime_pay, original_pay, totalpay):      print()     print("pay rate:       $", format (original_rate, '0,.2f'))     print("regular hours:   ", format (original_hours, '0,.0f'))     print("overtime hours:  ", format (overtime_hours, '0,.0f'))     print("regular pay:    $", format (original_pay, '0,.2f'))     print("overtime pay:   $", format (overtime_pay, '0,.2f'))     print("total pay:      $", format (totalpay, '0,.2f'))  def greet ():     print("this program calculates pay.")     print()       main() 

i didn't see assignment you. anyway, focus on variable assignment, if return n value(s), receive n variables calling otherwise, following error:

typeerror: int() argument must string or number, not 'tuple' 

your program kind of mess. now, it's been fixed!

overtime_rate_constant = .5  overtime_limit = 40  overtime_hours = 0  def main ():     greet()     original_hours,overtime_hours = get_hours()     original_rate = get_rate()      overtime_pay, original_pay = calculate_pay(original_hours, original_rate)     totalpay = overtime_pay + original_pay     print_data(original_rate, overtime_hours, original_hours, overtime_pay, original_pay, totalpay)  def get_hours ():          original_hours = int(input("please enter hours worked (8-86): "))     print()      while original_hours < 8 or original_hours > 86:         print("you must enter between 8 - 86 hours.")         print()         original_hours = int(input("please try again: "))         print()       #original_hours = int(original_hours)     original_hours in range (41, 86):         overtime_hours = original_hours - overtime_limit     return original_hours, overtime_hours         #return original_hours    def get_rate ():      original_rate = int(input("please enter hourly rate: "))     print()     while original_rate < 7 or original_rate > 50:         print("you must enter pay rate between 7 - 50 dollars")         print()         rate = int(input("please try again: "))         print()         return original_rate     return original_rate def calculate_pay (original_hours, original_rate):      original_hours = int(original_hours)     original_rate = int(original_rate)      original_pay = original_hours * original_rate     overtime_pay = original_hours * original_hours + overtime_hours * .5      return overtime_pay, original_pay  def print_data (original_rate, overtime_hours, original_hours, overtime_pay, original_pay, totalpay):      print()     print("pay rate:       $", format (original_rate, '0,.2f'))     print("regular hours:   ", format (original_hours, '0,.0f'))     print("overtime hours:  ", format (overtime_hours, '0,.0f'))     print("regular pay:    $", format (original_pay, '0,.2f'))     print("overtime pay:   $", format (overtime_pay, '0,.2f'))     print("total pay:      $", format (totalpay, '0,.2f'))  def greet ():     print("this program calculates pay.")     print()  main() 

you missed different things in program. sorted out. showing errors fixed:

error 1:

traceback (most recent call last):   file "p.py", line 72, in <module>     main()   file "p.py", line 11, in main     original_pay = calculate_pay(original_hours, original_rate)   file "p.py", line 45, in calculate_pay     original_hours = int(original_hours) typeerror: int() argument must string or number, not 'tuple' 

error 2:

traceback (most recent call last):   file "p.py", line 72, in <module>     main()   file "p.py", line 12, in main     totalpay = overtime_pay + original_pay nameerror: global name 'overtime_pay' not defined 

error 3:

traceback (most recent call last):   file "p.py", line 73, in <module>     main()   file "p.py", line 14, in main     print_data(original_rate, overtime_hours, original_hours, calculate_overtime_hours, original_pay, totalpay) nameerror: global name 'calculate_overtime_hours' not defined 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -