Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python3 class A(object): def __init__(self, x,y): self.x = x self.y = y def foo1(self): self.x = 10 return self.x def foo2(self): self.y.x = 20 return

Python3

class A(object): def __init__(self, x,y): self.x = x self.y = y def foo1(self): self.x = 10 return self.x def foo2(self): self.y.x = 20 return self.y

class B(A): def __init__(self,x,y,z): A.__init__(self,x,y) self.z = z def foo1(self): self.x =5 return self.x def main(): b = B(1,2,3) print(b.foo1()) print(b.foo2())

main()

I want to get my value foo1 =5, foo2 =4 but it says that "AttributeError: 'int' object has no attribute 'x'"

Please fix the error.(Please not fix line 9 self.y.x = 20) part

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

More Books

Students also viewed these Databases questions

Question

b. Will new members be welcomed?

Answered: 1 week ago