Exception has occurred: TypeError unsupported operand type(s) for *: 'NoneType' and 'float'

Question:

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.

Asked By: Yami Dancho

||

Answers:

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 🙂

Answered By: nariman zaeim
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.