Sem POO
def total_vendas(valores):
return sum(map(int, valores))
entrada = input("Digite os valores das vendas separados por espaço: ")
valores = entrada.split()
total = total_vendas(valores)
print("O total de vendas foi:", total)
Com POO
class Vendas:
def __init__(self, v1, v2,v3):
self.__v1 = v1
self.__v2 = v2
self.__v3 = v3
self.valores = [v1, v2, v3]
def total(self):
return sum(map(int, self.valores))
def __str__(self):
return(
"Valor 1: {} | "
"Valor 2: {} | "
"Valor 3: {} | \n"
"Total de vendas: {}".format
(self.__v1, self.__v2, self.__v3, self.total())
)
vendas = Vendas(int(input("Digite o valor 1: ")),
int(input("Digite o valor 2: ")),
int(input("Digite o valor 3: ")))
print(vendas)