'Mathematical Expression Using Lists

I realize that the output is simply the base_q - (base_q * q_growth_rates), but I'm having trouble coding the multiplication and subtraction of the lists.

#Build a list named quantities to mimic the output shown below

#Using base_q and q_growth_rates generate the following list

this is what I have

base_q = 100
q_growth_rates = [-0.2, -0.1, 0.0, 0.09999999999999998, 0.2]

quantities = []
for num in q_growth_rates: 
   base_q - (base_q * num)

This is the list it is supposed to generate after

print (quantities)
[80.0, 90.0, 100.0, 110.0, 120.0]


Solution 1:[1]

You simply need to append each result to quantities.

quantities.append(base_q - (base_q * num))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 KrabbyPatty