Python Forum
Type Error: 'in' object is not callable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Type Error: 'in' object is not callable
#1
Star 
import statistics as s

class stats:
   
    def mode(self):
        self.mode = s.mode(self.value)
        return(self.mode)
    def median(self):
        self.median = s.median(self.value)
        return(self.median)
    def mean(self):
        self.mean = s.mean(self.value)
        return(self.mean)
    def __init__(self, value):
        self.value = value

if __name__ == "__main__":
        
        testval = [2,3,4,5,8,4,6,3,4,6,8,9,7,5,3,5,7,4,3,2,2,1,4,6,8,6,8,9,3]
        
        object1 = stats(testval)
        print(type(object1.mode()))
        print(type(object1.median))
        assert (object1.mode()) == 3
        assert (object1.median) == 5
        assert (object1.mean) == 5
Error:
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-20-1e939491cea4> in <module> 22 print(type(object1.mode())) 23 print(type(object1.median)) ---> 24 assert (object1.mode()) == 3 25 assert (object1.median) == 5 26 assert (object1.mean) == 5 TypeError: 'int' object is not callable
Reply


Messages In This Thread
Type Error: 'in' object is not callable - by nman52 - May-01-2021, 03:41 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  error in class: TypeError: 'str' object is not callable akbarza 2 559 Dec-30-2023, 04:35 PM
Last Post: deanhystad
  TypeError: 'NoneType' object is not callable akbarza 4 1,076 Aug-24-2023, 05:14 PM
Last Post: snippsat
  [NEW CODER] TypeError: Object is not callable iwantyoursec 5 1,435 Aug-23-2023, 06:21 PM
Last Post: deanhystad
  Wrong type error rowan_bradley 6 1,292 Aug-07-2023, 10:44 AM
Last Post: rowan_bradley
  Need help with 'str' object is not callable error. Fare 4 874 Jul-23-2023, 02:25 PM
Last Post: Fare
  Type Error: Unsupported Operand jhancock 2 1,260 Jul-22-2023, 11:33 PM
Last Post: jhancock
  TypeError: 'float' object is not callable #1 isdito2001 1 1,106 Jan-21-2023, 12:43 AM
Last Post: Yoriz
  'SSHClient' object is not callable 3lnyn0 1 1,196 Dec-15-2022, 03:40 AM
Last Post: deanhystad
  declaring object parameters with type JonWayn 2 919 Dec-13-2022, 07:46 PM
Last Post: JonWayn
  TypeError: 'float' object is not callable TimofeyKolpakov 3 1,498 Dec-04-2022, 04:58 PM
Last Post: TimofeyKolpakov

Forum Jump:

User Panel Messages

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