Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
real & imag part
#6
(May-10-2019, 10:39 AM)mcgrim Wrote: (and the imag) so what differs between one method and the other is the return value, which for what I need, must exclusively return a (or b depending on the method).

yes and I gave you example for that :-) here it is again

class Complex():
    def __init__(self, real, imag):
        self.real = real
        self.imag = imag
         
c = Complex(1, 2)
print(c.real)
print(c.imag)
Output:
1 2 >>>
for the second part
You understand that your method will always return None, right? There is no explicit return, so by default it will return None.
Then read this https://docs.python.org/3.7/library/stdtypes.html#truth
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
real & imag part - by mcgrim - May-10-2019, 09:52 AM
RE: real & imag part - by buran - May-10-2019, 10:24 AM
RE: real & imag part - by mcgrim - May-10-2019, 10:27 AM
RE: real & imag part - by buran - May-10-2019, 10:31 AM
RE: real & imag part - by mcgrim - May-10-2019, 10:39 AM
RE: real & imag part - by buran - May-10-2019, 10:47 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020