I am new to Python and know almost nothing. I am trying to interlink the functions to the constructor but am unable to. How to call the first 2 functions in a main function and the main function in constructor?
I could execute the code without _init_()
and exec()
by calling inpVal()
and check()
outside after creating object, but it is not showing any output when I am doing it in this way.
class Acute:
def _init_(self):
self.exec()
def inpVal(self):
print("Enter 3 positive integers(angles):")
self.ang1 = int(input())
self.ang2 = int(input())
self.ang3 = int(input())
def check(self):
if self.ang1 <=0 or self.ang2 <=0 or self.ang3 <=0:
print("Invalid Input")
elif self.ang1+self.ang2+self.ang3 != 180:
print("Not a Triangle")
elif self.ang1 >=90 or self.ang2 >=90 or self.ang3 >=90:
print("Not an Acute Triangle")
else:
print("Acute Triangle")
def exec(self):
self.inpVal()
self.check()
t1 = Acute()
I want that only an object creation statement will be there after the class declaration and the constructor will be called by default and from it the exec function will be called which will call the input and check functions.