Introduction to Programming using Python 1st Edition

Published by Pearson
ISBN 10: 0132747189
ISBN 13: 978-0-13274-718-9

Chapter 1 - Introduction to Computers, Programs, and Python - Programming Exercises - Page 28: 1.11

Answer

org= 312032486 birth=365*24*60*60//7 death= 365*24*60*60//13 addmigrant=365*24*60*60//45 pop=org+birth-death+addmigrant for i in range(1,5): #loop starts here, but the site doesn't support tabs in answers pop=pop+birth-death+addmigrant print(pop) #loop ends here

Work Step by Step

No. of seconds in a year= 365*24*60*60 No. of people born every 7 seconds=1 No. of people born in a year= Seconds in a year// 7 seconds =365*24*60*60//7 Similarly, no. of people dying in a year= seconds in a year// 13 seconds =365*24*60*60//13 Similarly, no. of immigrant added per year= seconds in a year// 45 seconds =365*24*60*60//45 OriginalPopulation=312032486 'birth' means certain people are added to the originalPopulation, death means certain people are eliminated from it; immigrant addition obviously means people being added to original population. So, for the first year: Population= originalPopulation + birth - death + immigrants Now, for the second year, the first year's population is the original population. And for the 3rd year it is the second year's and so on. We make a loop for it (since it repeats similar patterns) that runs 4 times (as we already have the population of the first year printed) The values are printed each time the loop runs.
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.