Jump to content

Python question - Basic.

X1XNobleX1X

Hello forums,

I need a little help with Grok. 

I'm really not sure what I'm suppose to do for this question. 

I know we're suppose to use "while" and times the input by 2 until it reaches 7,000,000,000. How how do I do this?

This is what I have at the moment:

 

alpha = int(input("Number of initial customers:"))
years = (alpha * 2)
while years == 7000000000:
  
  

 

This is what the program is suppose to do:

For a given number of initial customers, write a program to calculate how many years it will take to have everyone on the planet as a customer, assuming they continue to double each year. As an estimate, let's say the current human population is 7,000,000,000.

Your program should work like this:

 
 
 
 
Number of initial customers: 2
Number of years: 32
 

Here is another example:

 
 
 
 
Number of initial customers: 42
Number of years: 28

Your answer should be in whole years. For instance, if the answer is 1 year, then the number of customers after doubling once is greater than 7,000,000,000.

|CPU: Intel 5960X|MOBO:Rampage V Extreme|GPU:EVGA 980Ti SC 2 - Way SLI|RAM:G-Skill 32GB|CASE:900D|PSU:CorsairAX1200i|DISPLAY :Dell U2412M X3|SSD Intel 750 400GB, 2X Samsung 850 Pro|

Peripherals : | MOUSE : Logitech G602 | KEYBOARD: K70 RGB (Cherry MX Brown) | NAS: Synology DS1515+  - WD RED 3TB X 5|ROUTER: AC68U

Sound : | HEADPHONES: Sennheiser HD800 SPEAKERS: B&W CM9 (Front floorstanding) ,  B&W CM Center 2 (Centre) | AV RECEIVER : Denon 3806 | MY X99 BUILD LOG!

 

Link to comment
Share on other sites

Link to post
Share on other sites

alpha = int(input("Number of initial customers:")) 

years = 0

while alpha <= 7000000000:

  years = years + 1

  alpha = (alpha*2)

print 'Number of years:', years

i am not a native speaker of the english language

[spoiler=My Rig: ]CPU: i7-3770k@Stock | Ram: 3x4GB@1600Mhz | Graka: 660TI@Stock | Storage: 250GB 840Evo, 1x1TB,2x2TB,2x640GB,1x500GB (JBOD) + NAS: DLINK DNS-320 2x3TB Raid1

 
Link to comment
Share on other sites

Link to post
Share on other sites

 

alpha = int(input("Number of initial customers:")) 
years = 0
while alpha <= 7000000000:
  years = years + 1
  alpha = (alpha*2)
print 'Number of years:', years

 

Thank you so much.

The only problem, is it says when inputing 13671875

do this. 

Testing a case where the customers double to exactly 7000000000. Your submission did not produce the correct output. Your program output:

 
 
 
 
Number of initial customers:13671875
Number of years: 10
 

when it was meant to output:

 
 
 
 
Number of initial customers: 13671875
Number of years: 9

|CPU: Intel 5960X|MOBO:Rampage V Extreme|GPU:EVGA 980Ti SC 2 - Way SLI|RAM:G-Skill 32GB|CASE:900D|PSU:CorsairAX1200i|DISPLAY :Dell U2412M X3|SSD Intel 750 400GB, 2X Samsung 850 Pro|

Peripherals : | MOUSE : Logitech G602 | KEYBOARD: K70 RGB (Cherry MX Brown) | NAS: Synology DS1515+  - WD RED 3TB X 5|ROUTER: AC68U

Sound : | HEADPHONES: Sennheiser HD800 SPEAKERS: B&W CM9 (Front floorstanding) ,  B&W CM Center 2 (Centre) | AV RECEIVER : Denon 3806 | MY X99 BUILD LOG!

 

Link to comment
Share on other sites

Link to post
Share on other sites

 

Thank you so much.

The only problem, is it says when inputing 13671875

do this. 

Testing a case where the customers double to exactly 7000000000. Your submission did not produce the correct output. Your program output:

 
 
 
 
 
Number of initial customers:13671875
Number of years: 10
 

when it was meant to output:

 
 
 
 
 
Number of initial customers: 13671875
Number of years: 9

 

 

well "<=" means "equal or less than"

guess what "<" means.

 

 

 

alpha = int(input("Number of initial customers:")) 
years = 0
while alpha <= 7000000000:
  years = years + 1
  alpha = (alpha*2)
print 'Number of years:', years

 

 

don't give full solutions to problems. this won' help the OP after all ...

Mini-Desktop: NCASE M1 Build Log
Mini-Server: M350 Build Log

Link to comment
Share on other sites

Link to post
Share on other sites

Also, neat little "trick":

years += 1
alpha *= 2
Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×