Question

In "Rabbitville", the rabbit population squares each year. e.g. If you start with 4 rabbits, you'll...

In "Rabbitville", the rabbit population squares each year. e.g. If you start with 4 rabbits, you'll have 16 in 1 year, and 256 in 2 years. Once the population exceeds 10,000 bunnies, food will be scarce, and population will begin to decrease.

Write a function years_till_no_carrots that includes a WHILE loop. Given a single integer (# of starting rabbits) as an input, your function should output the number of whole years until the number of rabbits becomes larger than 10000. e.g. years_till_no_carrots(4) = 3 (start with 4 rabbits, population greather than 10000 & food scarce in 3 years)

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def years_till_no_carrots(n):
    population = n
    count = 0
    while(population<10000):
        population = population * population
        count += 1
    return count

# Testing
print(years_till_no_carrots(4))

3

Add a comment
Know the answer?
Add Answer to:
In "Rabbitville", the rabbit population squares each year. e.g. If you start with 4 rabbits, you'll...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Mapping the population of fish in a lake year and Pn+1 A quadratic model to predict...

    Mapping the population of fish in a lake year and Pn+1 A quadratic model to predict the number of fish (in thousands) in a lake based on the number of fish that were in the lake the preceding year is given by the function: Pn+1 = (2-0.01pm)P, -16 where p., is the number of fish in the lake (in thousands) at the start of the is the number of fish in the lake at the start of next year. 1.)...

  • 4.         Find the MIRR of each investment using the WACC as the discount rate. You currently...

    4.         Find the MIRR of each investment using the WACC as the discount rate. You currently own and operate a bar in Chicago called the Big Tap. Up until now you have only served beer and hard alcohol to your customers (no food), and all liquor served has been purchased through a distributor. Business has been good, but you have just bought and moved into a new building and are looking to further expand the bar's business. The new building...

  • Background: During your first business class, you saw the opportunity to bring white paper squares to...

    Background: During your first business class, you saw the opportunity to bring white paper squares to the Salisbury University market. On a whim, you started manufacturing low quality, thin, white, flexible squares of paper. Shockingly, your business took off and the company was successful in competing in a saturated market. Seeing the need for diversification, you launched a new specialty product with the hope of increasing sales and setting the business apart. With moderately good recording keeping and a solid...

  • Question 1 (40 marks) Refer to Table 1. Write the Excel formula for each cell marked...

    Question 1 (40 marks) Refer to Table 1. Write the Excel formula for each cell marked with "" in column C such that formula could be copied and pasted into columns D, and E using Microsoft Excel without further editing, There is no need to explicitly write the Excel formula for cells marked with "Copy & paste". Label each formula clearly with cell reference position. In many country towns of China, there is no western coffee shop such as Starbucks...

  • 1) What are the two hypotheses of this experiment? What are you predictions for each hypotheses...

    1) What are the two hypotheses of this experiment? What are you predictions for each hypotheses & briefly describe how you will test the given hypothesis and the one you generated. 2) What is a histogram AND why is it used for this lab instead of just plotting each individual's data? 3) Does the multi-year TRC (total ridge count) support each hypothesis? (explain your answer in terms of the shape and the position of the curve.) 4) What might account...

  • I just need the excel formula of C27 to C66 Question 1 (40 marks) Refer to...

    I just need the excel formula of C27 to C66 Question 1 (40 marks) Refer to Table 1. Write the Excel formula for each cell marked with “?” in column C such that formula could be copied and pasted into columns D, and E using Microsoft Excel without further editing. There is no need to explicitly write the Excel formula for cells marked with “Copy & paste”. Label each formula clearly with cell reference position. In many country towns of...

  • CMPS 12B Introduction to Data Structures Programming Assignment 2 In this project, you will write...

    can i get some help with this program CMPS 12B Introduction to Data Structures Programming Assignment 2 In this project, you will write a Java program that uses recursion to find all solutions to the n-Queens problem, for 1 Sns 15. (Students who took CMPS 12A from me worked on an iterative, non-recursive approach to this same problem. You can see it at https://classes.soe.ucsc.edu/cmps012a/Spring l8/pa5.pdf.) Begin by reading the Wikipcdia article on the Eight Queens puzzle at: http://en.wikipedia.org/wiki/Eight queens_puzzle In...

  • Answer the case study questions please and thank you BUSINESS PROBLEM-SOLVING CASE Walmart Versus Amazon and...

    Answer the case study questions please and thank you BUSINESS PROBLEM-SOLVING CASE Walmart Versus Amazon and the Future of Retail Walmart is the world's largest and most success- ful retailer, with more than $485 billion in 2016 For online shopping, Amazon has some clea advantages. Amazon has created a rec sales and nearly 11,700 stores worldwide, including and highly successful brand in online retailing. The more than 4,600 in the United States. Walmart has company has developed extensive warehousing facili...

  • Don't attempt if you can't attempt fully, i will dislike a nd negative comments would be...

    Don't attempt if you can't attempt fully, i will dislike a nd negative comments would be given Please it's a request. c++ We will read a CSV files of a data dump from the GoodReads 2 web site that contains information about user-rated books (e.g., book tit le, publication year, ISBN number, average reader rating, and cover image URL). The information will be stored and some simple statistics will be calculated. Additionally, for extra credit, the program will create an...

  • Don't attempt if you can't attempt fully, i will dislike and negative comments would be given...

    Don't attempt if you can't attempt fully, i will dislike and negative comments would be given Please it's a request. c++ We will read a CSV files of a data dump from the GoodReads 2 web site that contains information about user-rated books (e.g., book titnle, publication year, ISBN number, average reader rating, and cover image URL). The information will be stored and some simple statistics will be calculated. Additionally, for extra credit, the program will create an HTML web...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT