SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Y Daniel Lang
Chapter:
Programming
Exercise:
Programming Excercises
Question:22 | ISBN:978013274719 | Edition: 6

Question

(Population projection) Rewrite Exercise 1.11 to prompt the user to enter the number of years and displays the population after that many years. Here is a
sample run of the program:

Enter the number of years:5
The population in 5 years is 325932970
 

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

#Prompt the user to the number of years
Years=int(input('Enter the number of years: '))
#Calculate population projection
Population = int(312032487 + (((31536000 / 7) - (31536000 / 13)+ (31536000 / 45)) * Years))
#Display the result
print("The population in",Years,"years is", Population)

Output:

Enter the number of years: 5

The population in 5 years is 325932970

0 0

Discussions

Post the discussion to improve the above solution.