Explain what is the python doing

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Explain what is the python doing 

6. A scientist studying the universe has written the Python code below:
from pylab import *
def rate (z):
A = = 0.6
B = 0.5
C =
9.4
zdash =
return (zdash)
A*exp(-z/C) B*Z
to = 0
ZO = float (input("Please enter initial value: "))
float (input ("Please enter final time: "))
time_end =
number_of_steps
20
time_step =
=
time_end/number_of_steps
z = zeros(int (number_of_steps+1))
t = zeros(int (number_of_steps+1))
z [0]
zo
t [0]
= to
i = 0
print (i,z[i])
while i < number_of_steps:
i = i + 1
t[i]
z [i]
=
t[i-1]+time_step
=
z [i-1]+time_step*rate (z[i-1])
print (i, z[i])
The scientist knows that you have just finished SCIE1000, and so emails it to you to get some
advice. You run it, and enter two numbers. It gives the following output:
Please enter initial value: 0.1
Please enter final time: 10
0 0.1
1 0.3718254266066964
2 0.567233937130043
Transcribed Image Text:6. A scientist studying the universe has written the Python code below: from pylab import * def rate (z): A = = 0.6 B = 0.5 C = 9.4 zdash = return (zdash) A*exp(-z/C) B*Z to = 0 ZO = float (input("Please enter initial value: ")) float (input ("Please enter final time: ")) time_end = number_of_steps 20 time_step = = time_end/number_of_steps z = zeros(int (number_of_steps+1)) t = zeros(int (number_of_steps+1)) z [0] zo t [0] = to i = 0 print (i,z[i]) while i < number_of_steps: i = i + 1 t[i] z [i] = t[i-1]+time_step = z [i-1]+time_step*rate (z[i-1]) print (i, z[i]) The scientist knows that you have just finished SCIE1000, and so emails it to you to get some advice. You run it, and enter two numbers. It gives the following output: Please enter initial value: 0.1 Please enter final time: 10 0 0.1 1 0.3718254266066964 2 0.567233937130043
3 0.7078576294083201
4 0.8091316697378195
5 0.8821055956118914
6 0.9347074436372816
7 0.9726346885043051
8 0.9999864581494113
9 1.0197143082402373
10 1.033944716658461
11 1.0442103586631264
12 1.0516162493108738
13 1.0569592427060288
14 1.0608140584976962
15 1.063595250817454
16 1.065601867742315
17 1.067049646798249
18 1.0680942305349759
19 1.0688479096897523
20 1.069391699903605
Transcribed Image Text:3 0.7078576294083201 4 0.8091316697378195 5 0.8821055956118914 6 0.9347074436372816 7 0.9726346885043051 8 0.9999864581494113 9 1.0197143082402373 10 1.033944716658461 11 1.0442103586631264 12 1.0516162493108738 13 1.0569592427060288 14 1.0608140584976962 15 1.063595250817454 16 1.065601867742315 17 1.067049646798249 18 1.0680942305349759 19 1.0688479096897523 20 1.069391699903605
Expert Solution
steps

Step by step

Solved in 5 steps with 5 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY