I have to make a class named MyInteger
(1)variable_01 = MyInteger(1)
(2)(2)variable_02 = MyInteger(2.0)
(3)(3)variable_03 = MyInteger('3')
(4)(4)variable_04 = MyInteger([4,5,6])
(5)(5)variable_05 = variable_01 + '10'
variable_01==1
variable_02==2
variable_03==3
variable_04==0
variable_05==11
How do I code to get this value?
class MyInteger():
def __init__(self,variable):
self.Num = 0
if type(variable) == int :
self.Num= 1
elif type(variable) == float:
self.Num = 2
elif type(variable) == str:
self.Num = 3
elif type(variable) == list:
self.Num = 0
def __str__(self):
return str(self.Num)
So we came up to variable_04.
The variable_05 value cannot be derived as 11.
python class
Search for operator overloading
592 GDB gets version error when attempting to debug with the Presense SDK (IDE)
567 Understanding How to Configure Google API Key
593 Uncaught (inpromise) Error on Electron: An object could not be cloned
573 PHP ssh2_scp_send fails to send files as intended
564 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.