Converting quarters into months
A company has a challenge in separating data into months. It has received the following data:
| Quarter | Amount |
|---|---|
| Quarter 1 | 700 |
| Quarter 2 | 650 |
The split across the months within each quarter is equal. Your goal is to separate this data into a list format containing the amounts per month for the first two quarters.
Este exercício faz parte do curso
Financial Forecasting in Python
Instruções do exercício
- Create a list for
quarterscontaining the numerical units per quarter, and initialize a new empty listqrtlist. The latter step has been done for you. - Create a for loop that converts the
qrtin thequarterslist into months with the formularound(qrt/3, 2). Theround()function with the second argument2rounds the numbers down to a readable format. - Add the three equal values of
monthtoqrtlist. - Print the
qrtlist.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Create a list for quarters and initialize an empty list qrtlist
quarters = [____, 650]
qrtlist = []
# Create a for loop to split the quarters into months and add to qrtlist
for qrt in ____:
month = round(____ / 3, 2)
qrtlist = qrtlist + [____, ____, ____]
# Print the result
print("The values per month for the first two quarters are {}.".format(____))