mercredi 13 février 2019

Why does this while loop not execute under the if statement?

I am new to python and stackoverflow. I am trying to learn by working on small projects

The project is on population: In 2014 China’s population was about 1.37 billion and growing at the rate of .51% per year. In 2014 India’s population was about 1.26 billion and growing at the rate of 1.35% per year. Determine when India’s population will surpass China’s population. Assume that the 2014 growth rates will continue

The code that I have used is:

year = 2014
population_chn = eval(input("Enter the initial China population:")) #1.37
population_ind = eval(input("Enter the initial Indian population:")) #1.26
while population_chn == 1.37:
    population_chn += 0.0051*population_chn
    year +=1
while population_ind == 1.26:
    population_ind += 0.0135*population_ind
    year +=1
if population_ind>population_chn:
    print("Indian population will exceed china population in",year)

However,There is no output when i run this. What am I missing? The output I desire is

India's population will exceed China's population in the year 2025.

Aucun commentaire:

Enregistrer un commentaire