Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

JohnM

  • 2 years ago

MIT Week6 homework -- Classes Question: Why does the code below output 10:30? Also, the homework asks us if paris_clock and boston_clock are different objects. I did an "is" test which returns True. But what am I supposed to learn from this? class Clock: def __init__(self, time): self.time = time def print_time(self): print self.time boston_clock = Clock('5:30') paris_clock = boston_clock paris_clock.time = '10:30' boston_clock.print_time() #ends up printing 10:30

  • This Question is Closed
  1. JohnM
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Can anyone tell me if I can edit a question after I post it?

  2. snark
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    i guess the point was to show that boston and paris are indeed the same object - when you set paris to 10:30, you have also set boston, the same object, to 10:30. paris would be an independant object had you used paris = Clock('5:30'), which would not have had any effect on boston.

  3. olasunmibo
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Paris and Boston clock are different object,the issue is assignment ,where Boston_clock is been assigned to Paris_clock, good lock

  4. Not the answer you are looking for?
    Search for more explanations.

    Search OpenStudy
    • Attachments:

Ask your own question

Ask a Question
Find more explanations on OpenStudy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.