Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE WRITE IN PYTHON (python3) This has three parts that build on top of each other. 1. the first part is just getting a json

PLEASE WRITE IN PYTHON (python3)
This has three parts that build on top of each other.
1. the first part is just getting a json data set. This data set has one key, 'turbidity_data', whose value is a time series list of dictionaries. Each dictionary in this list has the same set of keys. A sample of this data set is below:
image text in transcribed
please note that the complete data set is already given to us but will be used in the following parts.
2. write a python3 script that reads the water quality data set and prints three things a. the current water turbidity(taken as the average of the most recent five data points), b. whether that turbidity is below the safe threshold and c. the min time required for turbidity to fall below the safe threshold ( if already below safe threshold print 0 hrs). Some requirements:
A. the script must have a main() that is only called when executing script directly
B. use the python 'requests' library to import the json data
C. the script must have a mim of two additional functions. 1. a function to calculate turbidity using equation below 2. a function to calculate min time to fall below safe threshold using equation below.
D. the safe threshold is a constant, 1.0 NTU
E. the decay factor per hour is a constant. 2% or 0.02
equations:
image text in transcribed
^^ this is for the turbidity
image text in transcribed
^^ this is for finding the min time required to return below a safe threshold. it is expressed as an inequality and is a standard exponential decay function
the output should be similar to the below:
image text in transcribed
3. in a new python3 script, write unit tests to test the functions made in the previous script. the test script should work with 'pytest'. There must be at least one test associated with each function. They could simply perform math checks or something a bit more complicated including checking type returns
A template is below:
image text in transcribed
T=a0I90T=TurbidityinNTUUnits(040)a=CalibrationconstantI90=Ninetydegreedetectorcurrent Ts>T(1d)b Ts = Turbidity threshold for safe water To = Current turbidity d= decay factor per hour, expressed as a decimal b= hours elapsed Average turbidity based on most recent five measurements =1.1992 NTU Warning: Turbidity is above threshold for safe use Minimum time required to return below a safe threshold =8.99 hours Average turbidity based on most recent five measurements =0.9852 NTU Info: Turbidity is below threshold for safe use Minimum time required to return below a safe threshold =0 hours from my_module_name import func1, func2 import pytest def test_func1() : assert func1( info_to_pass_to_func1) == expected_value def test_func2() : assert func2( info_to_pass_to_func2 ) == expected_value

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

Identify the types of informal reports.

Answered: 1 week ago

Question

Write messages that are used for the various stages of collection.

Answered: 1 week ago