Global Class Questions

Viewed 38

So this is my code below. I am trying to figure out how to take the totals from the minute_total, num_txt_messages total, and the gb_data_used total and take all of them out and add them all together into a total. Then add the 20 from the total up top. I want to finally be able to take 3 columns from a dataframe and put all of those into the minutes, num_messages, and gb_used in the function of the class SurfPlan. Any ideas would be great!

class SurfPlan:
    def __init__(self, minutes, num_messages, gb_used):
        self.minutes = minutes
        self.num_messages = num_messages
        self.gb_used = gb_used
        self.total = 20
    
    def minute_total(self):
        if self.minutes <= 500:
            self.total += 0
            return self.total
        else:
            over_minute = self.minutes - 500
            self.total += over_minute * 0.03
            return self.total
    
    def num_txt_messages(self):
        if self.num_messages <= 50:
            self.total += 0
            return self.total
        else:
            over_message = self.num_messages - 50
            self.total += over_message * 0.03
            return self.total
    
    def gb_data_used(self):
        if self.gb_used <= 15:
            self.total += 0
            return self.total
        else:
            gb_exceeded = self.gb_used - 15
            self.total += gb_exceeded * 10
            return self.total
0 Answers
Related