Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON(NOT JAVA) HELP! THIS IS A3Q2 PYTHON CODE FOR GRAPHING: The python code for the above question is: #function to calculate the output value def

PYTHON(NOT JAVA) HELP!image text in transcribedimage text in transcribed THIS IS A3Q2 PYTHON CODE FOR GRAPHING:

The python code for the above question is:

#function to calculate the output value

def calc(t,r,p):

pt = float(r)*float(p)*(1-float(p))

return pt

#checking if time steps is a positive number

goodt=False

while not goodt:

try:

t = input('How many time steps to simulate ? : ')

if int(t)>0:

goodt=True

else:

print("Entered number is not a positive integer! Please try again.")

except ValueError:

print("Entered number is not a positive integer! Please try again.")

#checking if entered rate is a positive floating point number

goodr=False

while not goodr:

try:

r = input('What is the rate of change ? : ')

if float(r)>0:

goodr=True

else:

print("Entered number is not a positive floating point number! Please try again.")

except ValueError:

print("Entered number is not a positive floating point number! Please try again.")

#checking if entered starting population is between 0 and 1

goodp=False

while not goodp:

try:

p = input('What is the starting population ? : ')

if 0

goodp=True

break

else:

print("Entered number is not between 0 and 1! Please try again.")

except ValueError:

print("Entered number is not between 0 and 1! Please try again.")

time=int(t)

print("Time population ")

#time population between 0 to time entered

for i in range(0,time+1):

print(i," ",p)

p = calc(i,r,p)

i=i+1

Question 3 (6 points): Purpose: To learn some of the tools provided by a very practical and popular Python module. To practice Degree of Difficulty: The coding here is Easy. But read the steps carefully. there are things that could go This question builds on the model from the previous question. looking up specific details for modules on the Web. wrong! You don't need to have a deep knowiedge of psychology to realize that humans don't like staring at ta- bles of numbers very much. We prefer more visual representations of data. The Python module called matplotlib.pyplot is a module that provides Python programmers the tools to build professional quality data visualizations. We'll use it to produce simple graphs. Sample Run: Console input and visualization Sample input (input typed by the user is shown in green texti: Hov many tine steps to simulate? 5 What 's the rate of change? 2.7 What 's the starting population? 0.3 Instead of displaying the numbers to the console. your program will create a graph. It will pop up on the screen in a separate window Notice how the model parameters are part of the title! How to make a graph starting from A3Q2 1 Make a copy of your program from A3Q2, and name it a3q3.py. You should be fairly confident that 2. Add a Line of code at the top of your program to import matplotlib.pyplot as plot. Nothing that 3. Add a line of code that calls the figure ) function of matplotlib.pyplot to prepare Python for the it's correct before you start follows in this list will work if you skip this step, or use incorrect import syntax. creation of a new figure. This function should be called before computing any of the data you want to plot It has no effect you can see, but it creates a place in Python's memory for the graph 4. Add a Line of code that calls the sho) function of ratplotlib.pyplot. This function should be added at the end of your script, after all the calculations. This function displays a new window on your computer screen, and your graph will appear in this window. If you do not call this function, you will not see the graph, even if you follow all the other steps correctly Question 3 (6 points): Purpose: To learn some of the tools provided by a very practical and popular Python module. To practice Degree of Difficulty: The coding here is Easy. But read the steps carefully. there are things that could go This question builds on the model from the previous question. looking up specific details for modules on the Web. wrong! You don't need to have a deep knowiedge of psychology to realize that humans don't like staring at ta- bles of numbers very much. We prefer more visual representations of data. The Python module called matplotlib.pyplot is a module that provides Python programmers the tools to build professional quality data visualizations. We'll use it to produce simple graphs. Sample Run: Console input and visualization Sample input (input typed by the user is shown in green texti: Hov many tine steps to simulate? 5 What 's the rate of change? 2.7 What 's the starting population? 0.3 Instead of displaying the numbers to the console. your program will create a graph. It will pop up on the screen in a separate window Notice how the model parameters are part of the title! How to make a graph starting from A3Q2 1 Make a copy of your program from A3Q2, and name it a3q3.py. You should be fairly confident that 2. Add a Line of code at the top of your program to import matplotlib.pyplot as plot. Nothing that 3. Add a line of code that calls the figure ) function of matplotlib.pyplot to prepare Python for the it's correct before you start follows in this list will work if you skip this step, or use incorrect import syntax. creation of a new figure. This function should be called before computing any of the data you want to plot It has no effect you can see, but it creates a place in Python's memory for the graph 4. Add a Line of code that calls the sho) function of ratplotlib.pyplot. This function should be added at the end of your script, after all the calculations. This function displays a new window on your computer screen, and your graph will appear in this window. If you do not call this function, you will not see the graph, even if you follow all the other steps correctly

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions

Question

Is it clear what happens if an employee violates the policy?

Answered: 1 week ago