This is my code in python I keep getting these errors that do not match the expected output, I confused on what I did wrong how do I correct this.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section: Chapter Questions
Problem 9PP: (Data processing) Your professor has asked you to write a C++ program that determines grades at the...
icon
Related questions
Question
100%

This is my code in python I keep getting these errors that do not match the expected output, I confused on what I did wrong how do I correct this.

1 print('==> Bull Kelp and Purple Urchin Population Simulator <==\n')
2 print (¹ Model Parameters ---')
3
4
5 a float(input("Kelp growth rate: "))
6 if a < 0:
7
8
9
10 b = float(input("\nKelp death rate: "))
11 if b < 0:
12
13
14
15 c = float(input("\nUrchin birth rate: "))
16 if c < 0:
17
18
19
20 d = float(input("\nUrchin death rate: "))
21 if d < 0:
print("\nError: cannot have a negative growth rate")
41
42
43
44
45
46
47
48
49
exit()
22 print("\nError: cannot have a negative death rate")
23
exit()
24
25 k = max(0, float(input()))
26 u = max(0, float(input()))
50
51
27
28
29 print()
30 print('\n--- Initial Population ---')
31 print (f"Kelp population (in thousands) at t = 0: ")
32 print (f"Urchin population (in thousands) at t = 0: ")
33 print()
52
53
print("\nError: cannot have a negative death rate")
34 print('-- Simulation ---')
35
54
55
56
57
58
exit()
36
37 timescale = int(input("Timescale: "))
38 if timescale < 0:
39
40 else:
59
60
print("\nError: cannot have a negative birth rate")
exit()
61
62
63
64
65
66
print("Error: cannot have a negative timescale")
k_min= k
u_max = u
k_total k
u_total = U
for t in range(0, timescale + 1):
if t ==
timescale:
break
k0 = max(0, kak - b* k* u)
u0 = max(0, u + c *k* u - d * u)
k = k0
u = u0
print(f"Time t = {t}: {k:.3f}k kelp, {u:.3f}k urchins")
k_min= min(k, k_min)
u_max = max(u, u_max)
k_total += k
u_total + u
average_kelp = k_total / (timescale + 1)
average_urchin = u_total / (timescale + 1)
print("\n--- Simulation Statistics ---")
print (f"Average kelp population: {average_kelp:.3f}k")
print(f"Average urchin population: {average_urchin: .3f}k")
print (f"Min kelp population was {k_min:.3f}k at t={timescale}.000")
print (f"Max urchin population was {u_max:.3f}k at t={timescale}.000")
Transcribed Image Text:1 print('==> Bull Kelp and Purple Urchin Population Simulator <==\n') 2 print (¹ Model Parameters ---') 3 4 5 a float(input("Kelp growth rate: ")) 6 if a < 0: 7 8 9 10 b = float(input("\nKelp death rate: ")) 11 if b < 0: 12 13 14 15 c = float(input("\nUrchin birth rate: ")) 16 if c < 0: 17 18 19 20 d = float(input("\nUrchin death rate: ")) 21 if d < 0: print("\nError: cannot have a negative growth rate") 41 42 43 44 45 46 47 48 49 exit() 22 print("\nError: cannot have a negative death rate") 23 exit() 24 25 k = max(0, float(input())) 26 u = max(0, float(input())) 50 51 27 28 29 print() 30 print('\n--- Initial Population ---') 31 print (f"Kelp population (in thousands) at t = 0: ") 32 print (f"Urchin population (in thousands) at t = 0: ") 33 print() 52 53 print("\nError: cannot have a negative death rate") 34 print('-- Simulation ---') 35 54 55 56 57 58 exit() 36 37 timescale = int(input("Timescale: ")) 38 if timescale < 0: 39 40 else: 59 60 print("\nError: cannot have a negative birth rate") exit() 61 62 63 64 65 66 print("Error: cannot have a negative timescale") k_min= k u_max = u k_total k u_total = U for t in range(0, timescale + 1): if t == timescale: break k0 = max(0, kak - b* k* u) u0 = max(0, u + c *k* u - d * u) k = k0 u = u0 print(f"Time t = {t}: {k:.3f}k kelp, {u:.3f}k urchins") k_min= min(k, k_min) u_max = max(u, u_max) k_total += k u_total + u average_kelp = k_total / (timescale + 1) average_urchin = u_total / (timescale + 1) print("\n--- Simulation Statistics ---") print (f"Average kelp population: {average_kelp:.3f}k") print(f"Average urchin population: {average_urchin: .3f}k") print (f"Min kelp population was {k_min:.3f}k at t={timescale}.000") print (f"Max urchin population was {u_max:.3f}k at t={timescale}.000")
Output differs. See highlights below.
Input
Your output ends
with
Expected output
ends with
1.5
.001
.05
2.5
100
-2
5
▬▬
death rate:
Initial Population
Kelp population (in thousands) at t 0:
Urchin population (in thousands) at t 0:
Simulation
Timescale: Time t = 0: 250.000k kelp, 0.000k urchins
Time t = 1: 625.000k kelp, 0.000k urchins
1562.500k kelp, 0.000k urchins
Time t = 2:
Time t = 3: 3906.250k kelp, 0.000k urchins
Time t = 4: 9765.625k kelp, 0.000k urchins
Simulation Statistics
Average kelp population: 2701.562k
Average urchin population: 0.000k
Min kelp population was 100.000k at t=5.000
Max urchin population was 0.000k at t=5.000
Simulation
Timescale:
Time t 0: 100.000k kelp, 0.000k urchins
250.000k kelp, 0.000k urchins
Time t = 1:
Time t = 2: 625.000k kelp, 0.000k urchins
Time t 3: 1562.500k kelp, 0.000k urchins
Time t 4: 3906.250k kelp, 0.000k urchins
Time t = 5: 9765.625k kelp, 0.000k urchins
Simulation Statistics
Average kelp population: 01.56
Average urchin population: 0.000k
Min kelp population was 100.000k at t=0.000
Max urchin population was 0.000k at t=0.000
Transcribed Image Text:Output differs. See highlights below. Input Your output ends with Expected output ends with 1.5 .001 .05 2.5 100 -2 5 ▬▬ death rate: Initial Population Kelp population (in thousands) at t 0: Urchin population (in thousands) at t 0: Simulation Timescale: Time t = 0: 250.000k kelp, 0.000k urchins Time t = 1: 625.000k kelp, 0.000k urchins 1562.500k kelp, 0.000k urchins Time t = 2: Time t = 3: 3906.250k kelp, 0.000k urchins Time t = 4: 9765.625k kelp, 0.000k urchins Simulation Statistics Average kelp population: 2701.562k Average urchin population: 0.000k Min kelp population was 100.000k at t=5.000 Max urchin population was 0.000k at t=5.000 Simulation Timescale: Time t 0: 100.000k kelp, 0.000k urchins 250.000k kelp, 0.000k urchins Time t = 1: Time t = 2: 625.000k kelp, 0.000k urchins Time t 3: 1562.500k kelp, 0.000k urchins Time t 4: 3906.250k kelp, 0.000k urchins Time t = 5: 9765.625k kelp, 0.000k urchins Simulation Statistics Average kelp population: 01.56 Average urchin population: 0.000k Min kelp population was 100.000k at t=0.000 Max urchin population was 0.000k at t=0.000
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Top down approach design
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning