Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8696181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:13:10+00:00 2026-06-13T01:13:10+00:00

I am a beginner in Python and am working on an assignment. I keep

  • 0

I am a beginner in Python and am working on an assignment. I keep getting TypeError: unsupported operand type(s) for -: 'int' and 'function' even after researching the error and applying the suggested fixes. I’m not looking for anyone to hand me a solution, but I would appreciate a second look. I’m missing something but I don’t know what. This is the section of code I’m having trouble with:

month = 0
interestYDT = 0
balance = int(raw_input ("Enter balance on credit card: "))
annualInterestRate = float(raw_input ("Enter annual interest rate as a decimal: "))
monthlyPaymentRate = float(raw_input ("Enter minimum monthly payment rate as a decimal: "))
previousbalance = balance
#
def monthlyInterestRate(annualInterestRate):
    return float(annualInterestRate/12)
#
if month <= 12:
    def minimumMonthlyPayment(previousbalance):
        return (previousbalance * monthlyPaymentRate)
    def monthlyInterest(monthlyInterestRate):
        return (1 + monthlyInterestRate)
    minMonPay = minimumMonthlyPayment
    monInt = monthlyInterest
    newbalance = ((previousbalance - minMonPay) * (monInt))
    interestYDT = (interestYTD + montInt)
    previousbalance = (newbalance)
    print ''
    print ('Month:' (month))
    print ('Minimum monthly payment: $ ' (round(minimumMonthlyPayment, 2)))
    print ('Remainging balance: $ ' (round(newbalance, 2)))
    print ' '
    month = (month + 1)

This is the entire error I get:

Traceback (most recent call last):
  File "C:/Users/Karla/Documents/_MIT 600X Introduction to CS and Prog/Assignments/Week2/kmarciszewski_week2_Problemset_Problem1.py", line 33, in <module>
    newbalance = ((previousbalance - minMonPay) * (monInt))
TypeError: unsupported operand type(s) for -: 'int' and 'function'

I’d really appreciate any insight. Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:13:11+00:00Added an answer on June 13, 2026 at 1:13 am

    In order to call a function you must add parens after the function name, as well as any required parameters.

    In these two lines

    minMonPay = minimumMonthlyPayment
    monInt = monthlyInterest
    

    you assign the functions to the names minMonPay, monInt, but you don’t actually call them. Rather, you would need to write something like:

    minMonPay = minimumMonthlyPayment(previousBalance)
    monInt = monthlyInterest(monthlyInterestRate)
    

    This definition

    def minimumMonthlyPayment(previousbalance):
        return (previousbalance * monthlyPaymentRate)
    

    gives you a function that takes one parameter and calls it previousBalance. It has nothing to do with the variable you created earlier in your code. In fact, I suggest you rename it, it can only serve to confuse you as a beginner.

    Further, the functions you’ve created are so simple, and only used once each, that it might be in your interest to remove them and inline the code.

    # OLD CODE
    def minimumMonthlyPayment(previousbalance):
        return (previousbalance * monthlyPaymentRate)
    def monthlyInterest(monthlyInterestRate):
        return (1 + monthlyInterestRate)
    minMonPay = minimumMonthlyPayment
    monInt = monthlyInterest
    
    # NEW CODE
    minMonPay = previousbalance * monthlyPaymentRate
    monInt = 1 + monthlyInterestRate
    

    Dont forget to update the line that incorrectly uses the minimumMonthlyPayment function if you do this.

    # OLD CODE
    print ('Minimum monthly payment: $ ' (round(minimumMonthlyPayment, 2)))
    
    # NEW CODE
    print ('Minimum monthly payment: $ ' (round(minMonPay, 2)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As part of the last assignment in a beginner python programing class, I have
I am beginner in python, and I need to use some thirdparty function which
I'm trying to get simple code working, unfortunately I'm a python beginner. My script
I am python beginner and have a question.. I have a class function looks
Python beginner here. I'm working with diffs at the moment. I'm generating them with
I've got a question related to a beginner Python snippet I've written to introduce
Python beginner here, I have a list of lists and want to refer to
Python beginner here. I have a text file that is sorted into columns: fields
I'm a Python beginner and have just started using packages. When you're calling a
I am a beginner of Python. I am trying now figuring out why the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.