0
class sınıf():
   
    def area(r):
        return (22.0/7)*r*2
    def area(a,b):
        return (22*5)

print(sınıf.area(5))
print(sınıf.area(5,2))
     print(sınıf.area(5))
TypeError: area() missing 1 required positional argument: 'b' 

How do we solve this problem? missing 1 required positional argument

khelwood
  • 55,782
  • 14
  • 81
  • 108
Berat
  • 27
  • 3
  • 1
    Python does not support function overloading. GIve it a different name, or optional arguments: eg, def area(x, b=None): – Max Feb 17 '22 at 19:48
  • Python does not support function overloading, so generally you don't. You can make `b` default to None, and then check if `b is None` and do the other version. You can also use singledispatch _if_ a single argument only differs by type: https://docs.python.org/3/library/functools.html#functools.singledispatch – MatsLindh Feb 17 '22 at 19:48
  • Note: you can use math.pi. And `r*2` is not r-squared. – jarmod Feb 17 '22 at 19:49

0 Answers0