Nt1310 Unit 1 Pdf

454 Words2 Pages

class App(): number1 = 0 number2 = 0 operator = '' # Operators # 1) Add (+) # 2) subtract (-) # 3) Multiply (*) # 4) Divide (/) def getFirstNumber(self): #Gets first number from user self.number1 = self.__checkNumber("Please enter the first number: ") def getSecondNumber(self): #Gets second number from user self.number2 = self.__checkNumber("Please enter the second number: ") def __checkNumber(self, strMessage): #Ensures imputed value is a number loop = True while loop: try: userInput = float(input(strMessage)) except ValueError: print("Please enter …show more content…

else: return userInput loop = False def calculate(self): if self.number1.is_integer() == True: self.number1 = int(self.number1) if self.number2.is_integer() == True: self.number2 = int(self.number2) if self.operator == '1': ret = self.Add() elif self.operator == '2': ret = self.Subtract() elif self.operator == '3': ret = self.Multiply() elif self.operator == '4': ret = …show more content…

Please select a valid number from the menu above" __intNumPossibleOptions = [] __strSelectedOption = '0' def __header(self, text =

More about Nt1310 Unit 1 Pdf