The Big Mac Index, created by the British weekly magazine The Economist in 1986, is an informal method of calculating purchasing power parity based on the price of a Big Mac in a specific country. The index compares different currencies to a chosen base currency. By comparing the purchasing power of this base currency with that of another currency, you can determine how much that currency is "really" worth and whether the exchange rate is too high or too low.
Instantiate your global variables country_name
with an empty string and index
with the value 0.0
(float) on the first lines.
create_big_mac_index(country: str)
with the name of a country as an argument. This function initializes the global variables, where country_name
represents the name of the country, and index
represents the Big Mac index with a value of 0.0
.get_country_name()
and get_index()
that return the name of the country and the index, respectively.set_country_name(new_country_name)
and set_index(new_index)
that respectively modify the global variables country_name
and index
with the new values.
calculate_big_mac_index(price, price_compare)
with the arguments being the price of a Big Mac in the country for which you want to calculate the Big Mac Index and the price of a Big Mac in the country you want to compare with. The function will then determine the value for the global variable index
by dividing the price of a Big Mac in the country for which you want to calculate the Big Mac Index by the price of a Big Mac in the country you want to compare with.
global
. For example, if you want to modify the global variable x
within a function, you must first include a line global x
in your function before you can modify that global variable. This keyword informs Python that our x
within the function is the global x
and not a local x
that exists only within the function.