Asgard is a fictional realm and it is a capital city appearing in American comic books…

Asgard is a fictional realm and it is a capital city appearing in American comic books published by Marvel Comics. You may have heard about it in Marvel Studios movies like Avengers, Thor, and Captain America. Asgard is home to the Asgardians and other living beings such as Demons and Giants. The resources of Asgard are limited and power struggle keeps the wars active among different living beings. A scientist from Earth went to Asgard to analyze the situation. He collected historical data of wars and represented the relationship of population among Asgardians, Demons and Giants living in Asgard by the following difference equations.. Dn -0.01 Gn+1)/10 (3) where A, G and D represent the population of Asgardians, Giants and Demons respectively living in Asgard, n represents the generation number while b, c, k and m are the constants having positive values. The scientist needs to write the code to simulate the above difference equation and help Thor (Contender for the throne of Asgard) to forecast the population of all three living beings in Asgard. As a programmer, you need to write a function in Python and help the scientist. The inputs to the function are initial population of all three living beings Ao, Go and Do, number of generations p and values for constants b, c, k and m. The inputs should be in the same sequence as they are mentioned The required output of the function are three lists (A, G and D) containing the population of all three living beings for all generations up to and including the pth generation, following by the maximum populations(Amax, Gmax and Dmax) of all three living beings over p generations. Remember following rules for your function: The first generation is considered as initial population (zero generation) provided by Ao, Go and Do and is stored as first element in the lists of populations. Sequence of calculating generations of each living being is same as provided in the sequence of above mentioned difference equations. * The population cannot be in fraction and must always be rounded off The population should be approximated to zero if it becomes smaller than zero. In other words, negative population should be approximated to zero. The order of output of function should be A, G, D, Amax, Gmax and Dmax. None of the inputs to the function can be negative. In case any input to the function is provided as negative, then function should be terminated after displaying a message. Include your name and student ID as a comment in the first row of your function file Save your python file with name YourLastName_StudentID. E.g Thor12345678.py Note:Do not print the lists in a formatted manner, simply return them at the end ofcalculations Your submission will be tested against a sample solution with numerous test-cases in addition to the one presented below Sample testing data A,G,D, Amax,Gmax,Dmax asgard(40,25,30,10,0.01,0.01,0.2,0.5) A [40,41,42, 43, 44, 45, 46, 47, 48, 49, 50] G 125, 24, 23, 22, 21, 20, 19, 18, 17, 16,15] D [30, 31, 32, 33, 34, 35,37, 39, 41, 43, 45 Amax = 50 Gmax-25 Dmax45

Asgard is a fictional realm and it is a capital city appearing in American comic books published by Marvel Comics. You may have heard about it in Marvel Studio’s movies like Avengers, Thor, and Captain America. Asgard is home to the Asgardians and other living beings such as Demons and Giants. The resources of Asgard are limited and power struggle keeps the wars active among different living beings. A scientist from Earth went to Asgard to analyze the situation. He collected historical data of wars and represented the relationship of population among Asgardians, Demons and Giants living in Asgard by the following difference equations.. Dn -0.01 Gn+1)/10 (3) where A, G and D represent the population of Asgardians, Giants and Demons respectively living in Asgard, n represents the generation number while b, c, k and m are the constants having positive values. The scientist needs to write the code to simulate the above difference equation and help Thor (Contender for the throne of Asgard) to forecast the population of all three living beings in Asgard. As a programmer, you need to write a function in Python and help the scientist. The inputs to the function are initial population of all three living beings Ao, Go and Do, number of generations p and values for constants b, c, k and m. The inputs should be in the same sequence as they are mentioned The required output of the function are three lists (A, G and D) containing the population of all three living beings for all generations up to and including the pth generation, following by the maximum populations(Amax, Gmax and Dmax) of all three living beings over p generations. Remember following rules for your function: The first generation is considered as initial population (zero generation) provided by Ao, Go and Do and is stored as first element in the lists of populations. Sequence of calculating generations of each living being is same as provided in the sequence of above mentioned difference equations. * The population cannot be in fraction and must always be rounded off The population should be approximated to zero if it becomes smaller than zero. In other words, negative population should be approximated to zero. The order of output of function should be A, G, D, Amax, Gmax and Dmax. None of the inputs to the function can be negative. In case any input to the function is provided as negative, then function should be terminated after displaying a message. Include your name and student ID as a comment in the first row of your function file Save your python file with name YourLastName_StudentID. E.g Thor12345678.py Note:Do not print the lists in a formatted manner, simply return them at the end ofcalculations Your submission will be tested against a sample solution with numerous test-cases in addition to the one presented below Sample testing data A,G,D, Amax,Gmax,Dmax asgard(40,25,30,10,0.01,0.01,0.2,0.5) A [40,41,42, 43, 44, 45, 46, 47, 48, 49, 50] G 125, 24, 23, 22, 21, 20, 19, 18, 17, 16,15] D [30, 31, 32, 33, 34, 35,37, 39, 41, 43, 45 Amax = 50 Gmax-25 Dmax45

Expert Answer

answers

######################### PYTHON CODE ############################

Don't use plagiarized sources. Get Your Custom Essay on
Asgard is a fictional realm and it is a capital city appearing in American comic books…
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT!
Order Essay

def asgard(A_0G_0D_0pbckm):

 

# Checking for negative input

if True in map(lambda x: x < 0, [A_0, G_0, D_0, p, b, c, k, m]):

print(‘Error. A negative input was provided.nTerminating.’)

return

# Initializing the list of populations with the initial populations

A = [A_0]

G = [G_0]

D = [D_0]

# Looping p times to add the population of ith generation to the lists

for i in range(p):

# calculate the next population

Anext = A[-1] + (k*A[-1] – 0.1*D[-1]) / 5

# if negative, make it 0

if Anext < 0:

Anext = 0

# else, round it off

else:

Anext = round(Anext)

Gnext = G[-1] + (0.001*G[-1]*D[-1] – m*G[-1]) / 10

if Gnext < 0:

Gnext = 0

else:

Gnext = round(Gnext)

Dnext = D[-1] + (b*D[-1]*Anext – c*D[-1] – 0.01*Gnext) / 10

if Dnext < 0:

Dnext = 0

else:

Dnext = round(Dnext)

# Add the calculated populations to the lists

A.append(Anext)

G.append(Gnext)

D.append(Dnext)

# Storing the maxmimum for each of the lists

Amax = max(A)

Gmax = max(G)

Dmax = max(D)

# Returning the required lists and values

return A, G, D, Amax, Gmax, Dmax

###################################################################

1 def asgard(A-0, GO, DO, p, b, c, k, m): # Checking for negative input if True in map(lambda x: x < θ, [Ae, Ge, De, p, b, c, k, m]): 4 print( Error. A negative input was provided. InTerminating.) return # Initializing the list of populations with the initial populations A [A e] G = [Ge] D [0,0] 9 10 13 # Looping p times to add the population of ith generation to the lists 14 for i in range (p): 15 16 17 18 19 20 21 # calculate the next population # if negative, make it 0 if Anext e: Anext = θ # else, round it else: Anext round (Anext) Gnext GI-1] (0.001 GI-1] DI-1] - mGI-1]) / 18 if Gnext 8 23 24 25 26 27 28 29 30 31 32 Gnext else: Gnext - round(Gnext) if Dnext 8 else: Dnext round (Dnext) 34 35 36 # Add the calculated populations to the lists A.append (Anext) G.append (Gnext) D.append (Dnext)

Top Grade Homework
Order NOW For a 10% Discount!
Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional and Experienced Academic Writers

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.

× Contact Live Agents