Code:
population_china = 1420062022
population_india = 1368737513
years = 0
while population_china >= population_india:
population_china *= 1.0035
population_india *= 1.0108
years += 1
print(years)
Output:
6
Step-by-step explanation:
Using a while loop would probably be of greater use than a for loop since we are increasing the population growth of both countries until India's population surpasses China's population (so a condition needs to be set).
Looking at the code, we first set the original population of both countries in their own variables (population_china, population_india). We also set the 'years' variable at 0, which will increase with respect to the yearly population growths of both countries. In the while loop, the condition population_china >= population_india will allow for the variable 'years' to increase until population_india surpasses population_china. Once India's population is larger than China's population, we are left with the number of years it takes for India's population to surpass China's population, which is 6 years.
Hope this helps :)