Question: [In Python] Q: The world population reached 7 billion people on October 21, 2011 and was growing at the rate of 1.1% each year. Assuming

[In Python] Q: The world population reached 7 billion people on October 21, 2011 and was growing at the rate of 1.1% each year. Assuming that the population continues to grow at the same rate, write a Python program that prints approximately when will the population reach 8 billion and 9 billion respectively?

My Code:

#Name #Program that gives the year for when a population threshold is met.

# year = 2011 population = 7000000000 rate = 0.011

print("Enter a number for the population year you want to find") print("8. Population reaches 8 billion") print("9. Population reaches 9 billion") while True: num = int(input("Please enter one of the two numbers: ") if num == 8: population += rate * pop year += 1 if population >= 8000000000 break print('Population will exceed 8 billion by year ' + str(year)) elif num == 9: population += rate * population year += 1 if population >= 9000000000 break print('Population will exceed 9 billion by year ' + str(year))

Note: This is what I got so far, but I keep getting an invalid syntax error despite what changes I make. Could you help me get the code to work?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!