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

  • Home
  • SEARCH
  • 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 6376803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:47:28+00:00 2026-05-25T01:47:28+00:00

Can someone please explain why I’m getting this error? My code: def x(n): if

  • 0

Can someone please explain why I’m getting this error? My code:

def x(n):
    if n == 1: n = 4
    elif n == 2: n = 3
    elif n == 3: n = 2
    elif n == 4: n = 1
    return n

def y(n):
    if n == 1: n = 2
    elif n == 2: n = 1
    elif n == 3: n = 4
    elif n == 4: n = 3
    return n

def query_x(i, j, quadrants):
    quadrants[i-1:j] = map(x, quadrants[i-1:j])

def query_y(i, j, quadrants):
    quadrants[i-1:j] = map(y, quadrants[i-1:j])

def query_c(i, j, quadrants):
    count = [quadrants[i-1:j].count(n) for n in range(1,5)]
    print "%d %d %d %d" % (count[0], count[1], count[2], count[3])

def process_queries(queries, quadrants):

    for query in queries:
        if   query[0] == "X": query_x(query[1], query[2], quadrants)
        elif query[0] == "Y": query_y(query[1], query[2], quadrants)
        elif query[0] == "C": query_c(query[1], query[2], quadrants)

if __name__ == "__main__":

    N = int(raw_input())

    quadrants = []
    for i in xrange(N):
        pair = map(int, raw_input().split())
        x, y = pair

        if   x > 0 and y > 0: quadrants.append(1)
        elif x < 0 and y > 0: quadrants.append(2)
        elif x < 0 and y < 0: quadrants.append(3)
        elif x > 0 and y < 0: quadrants.append(4)

    Q = int(raw_input())

    queries = []
    for i in xrange(Q):
        query = raw_input().split()
        queries.append([query[0], int(query[1]), int(query[2])])

    process_queries(queries, quadrants)

Output:

4
1 1
-1 1
-1 -1
1 -1
5
C 1 4
X 2 4
C 3 4
Y 1 2
C 1 3
1 1 1 1
Traceback (most recent call last):
  File "QuadrantQueries_dev.py", line 53, in <module>
      process_queries(queries, quadrants)
  File "QuadrantQueries_dev.py", line 28, in process_queries
      if   query[0] == "X": query_x(query[1], query[2], quadrants)
  File "QuadrantQueries_dev.py", line 16, in query_x
      quadrants[i-1:j] = map(x, quadrants[i-1:j])
  TypeError: 'int' object is not callable
  • 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-05-25T01:47:28+00:00Added an answer on May 25, 2026 at 1:47 am
    pair = map(int, raw_input().split())
    x, y = pair
    

    On line 39 you are redefining the x and y objects to be integers. x and y no longer reference the functions that you defined at the top. Your “main” block of code is not a separate function scope you are still at the global namespace.

    http://docs.python.org/tutorial/classes.html#python-scopes-and-namespaces

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone please explain to me why I keep getting this PLS-00905 error for
Can someone please explain what does this code do? def stemmer(word): [(stem,end)] = re.findall('^(.*ss|.*?)(s)?$',word)
Can someone please explain to me the below code. This behavior has been like
Can someone please explain why this JavaScript code outputs zero instead of one? Also,
Can someone please explain this piece of code? struct Class { boost::function<void()> member; };
Can someone please explain why this program outputs 0x00000004? class AndAssignment { static void
can someone please explain why the addition of the group by subquery makes this
Can someone please explain to me why this simple assignment doesn't work. Here is
Can someone please explain the structure of this line of a script for me?
Can someone please explain what this means? Enum<T extends Enum<T>> This seems like a

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.