Menu Close

Country A and B, how many years the population of A surpasses B.

The country A has 50M inhabitats and its population grows 3% per year. The country B, 70M and grows 2% per year.The above is just a sample- see input and output. Tell, in how many years A will surpass B.
Input method: get integer value and print integer value. How many years A surpasses B.

A=int(input("Enter the population of city A: "))
B=int(input("Enter the population of city B: "))
years=0
while(A<=B):
	A=(A*0.03)+A
	B=(B*0.02)+B
	years+=1

print("A will surpass B in {} years".format(years))

Sample Input’s..?
Input_1:
         Enter the population of city A: 50000000  #(50 Million)
         Enter the population of city B: 70000000  #(70 Million)
Output:
         A will surpass B in 35 years


Input_2:
        Enter the population of city A: 10000 
        Enter the population of city B: 20000
Output:
         A will surpass B in 72 years


exec. on terminal

Output Video here ?

More Codes to Fcuk