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 1808722
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:17:52+00:00 2026-05-17T06:17:52+00:00

Level: Beginner In the following code my ‘samePoint’ function returns False where i am

  • 0

Level: Beginner

In the following code my ‘samePoint’ function returns False where i am expecting True. Any hints?

import math

class cPoint:
    def __init__(self,x,y):
        self.x = x
        self.y = y
        self.radius = math.sqrt(self.x*self.x + self.y*self.y)
        self.angle = math.atan2(self.y,self.x)
    def cartesian(self):
        return (self.x, self.y)
    def polar(self):
        return (self.radius, self.angle)

class pPoint:
    def __init__(self,r,a):
        self.radius = r
        self.angle = a
        self.x = r * math.cos(a)
        self.y = r * math.sin(a)
    def cartesian(self):
        return (self.x, self.y)
    def polar(self):
        return (self.radius, self.angle)

def samePoint(p, q):
    return (p.cartesian == q.cartesian)

>>> p = cPoint(1.0000000000000002, 2.0)
>>> q = pPoint(2.23606797749979, 1.1071487177940904)
>>> p.cartesian()
(1.0000000000000002, 2.0)
>>> q.cartesian()
(1.0000000000000002, 2.0)
>>> samePoint(p, q)
False
>>> 

source: MIT OpenCourseWare http://ocw.mit.edu Introduction to Computer Science and Programming Fall 2008

  • 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-17T06:17:52+00:00Added an answer on May 17, 2026 at 6:17 am

    Looking at your code

    def samePoint(p, q):
        return (p.cartesian == q.cartesian)
    

    p.cartesian, q.cartesian are functions and you are comparing function rather than function result. Since the comparing two distinct functions, the result is False

    What you should have been coding is

    def samePoint(p, q):
        return (p.cartesian() == q.cartesian())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

level: beginner the following code will print 'False' def function(x): if len(x) == 5:
This is a beginner level question for asp.net MVC I have the following code
Level: Beginner I'm doing my first steps in Object Oriented programming. The code is
query level: beginner As part of a learning exercise I have written code that
I'm looking for suggestions for a beginner level ASP/XML test. Essentially I'm trying to
This is a beginner-level question. I have a catalog of mtypes: mtype_id name 1
Beginner level question Scenario: Have simple string cocantation tool, that I might expand later
I'm a beginner level programmer trying to make a game app for the iphone
I have a beginner level Json question with MVC.net (I've never really used jquery
level: beginner word= 'even' dict2 = {'i': 1, 'n': 1, 'e': 1, 'l': 2,

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.