Home > front end >  Exception has occurred: TypeError unsupported operand type(s) for *: 'NoneType' and '
Exception has occurred: TypeError unsupported operand type(s) for *: 'NoneType' and '

Time:11-26

Code is correct, has an output, but gets the error message.

import math

class Prelim:
    def __init__(self):
        self.LA1 = int(input('Enter your grade in Lab Activity #1: ')) #100
        self.LA2 = int(input('Enter your grade in Lab Activity #2: ')) #100
        self.LA3 = int(input('Enter your grade in Lab Activity #3: ')) #100
        
    def displayLAG(self):  
        self.LAG = int(print((self.LA1   self.LA2   self.LA3) / 3) * 0.25)
        
la1 = Prelim()
la1.displayLAG()
Output: 
Enter your grade in Lab Activity #1: 84
Enter your grade in Lab Activity #2: 98
Enter your grade in Lab Activity #3: 91
91.0

I tried to remove float and changed it to int and also none at all.

CodePudding user response:

just wrong usage of print command. use code below:

import math
class Prelim:
    def __init__(self):
        self.LA1 = int(input('Enter your grade in Lab Activity #1: ')) #100
        self.LA2 = int(input('Enter your grade in Lab Activity #2: ')) #100
        self.LA3 = int(input('Enter your grade in Lab Activity #3: ')) #100
        
    def displayLAG(self):  
        result= int((self.LA1   self.LA2   self.LA3) / 3)
        print(result)
        self.LAG=result*0.25
        
la1 = Prelim()
la1.displayLAG()

have fun :)

  • Related