Skip to content

Instantly share code, notes, and snippets.

@thejsj
Last active November 11, 2021 20:45
Show Gist options
  • Save thejsj/6151778 to your computer and use it in GitHub Desktop.
Save thejsj/6151778 to your computer and use it in GitHub Desktop.
A little python script to calculate GDP Growth. There are multiple ways to do it; this is just one of them. By this standard, Spain had the 3rd highest GDP growth in the original eurozone (11 countries) from the first quarter 1999 to the last quarter of 2007.
import math
import operator
number_of_quarters_in_a_year = 4;
number_of_quarters = 9 * number_of_quarters_in_a_year;
countries = [
{ "name" : "Belgium", "starting_growth" : 58433.0, "end_growth" : 85113.0},
{ "name" : "Germany", "starting_growth" : 493890.0, "end_growth" : 614660.0},
{ "name" : "Ireland", "starting_growth" : 21348.8 ,"end_growth" : 48091.5},
{ "name" : "Spain", "starting_growth" : 140061.0, "end_growth" : 269272.0},
{ "name" : "France", "starting_growth" : 336010.0, "end_growth" : 478947.0},
{ "name" : "Italy", "starting_growth" : 278506.8 , "end_growth" :393297.6},
{ "name" : "Luxembourg", "starting_growth" : 4739.1, "end_growth" : 9505.6},
{ "name" : "Netherlands", "starting_growth" : 93980.4, "end_growth" : 146015.8},
{ "name" : "Austria", "starting_growth" : 48714.4, "end_growth" : 69481.2},
{ "name" : "Portugal", "starting_growth" : 28971.3, "end_growth" : 42906.0},
{ "name" : "Finland", "starting_growth" : 29969.0, "end_growth" : 46134.0}
];
# http://www.optimist123.com/optimist/2006/09/how_to_calculat.html
for country in countries:
country["quarter_growth_index"] = math.exp((math.log(country["end_growth"] / country["starting_growth"]))/number_of_quarters);
country["annual_growth_index"] = country["quarter_growth_index"] ** number_of_quarters_in_a_year;
country["annualized_percent_growth"] = (country["annual_growth_index"] - 1) * 100;
country["jorge_growth"] = country["end_growth"] / country["starting_growth"];
countries = sorted(countries, key=lambda k: k['annual_growth_index'], reverse=True)
for i,country in enumerate(countries):
print i,". ",country["name"], " -- ", country["annual_growth_index"] , " - " , country["jorge_growth"]
@Soufiane000
Copy link

HAHA You peace of shit. did you thougth we wont notice the link. asshole.

@Soufiane000
Copy link

actually you got me. xD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment