PYTHON The data is given as a list of integer with comma separated in the order , (i.e. [ ,,...., ,] ). This data represents the weight of the load at the given time. For example: l = [0, 12, 5, 60, 10, 80, 13, 35] where 0 (l[0]), 5 (l[2]), 10 ([l[4]), 13 (l[6]) are (time values) and 12 (l[1]), 60 (l[3]), 80 (l[5]), 35 (l[7]) are (weight load) The data must follow specific format: 1. The time values must be defined incrementally 2. No duplicate time values Write a function in python that checks the data to determine if the data follows the required format. If the data follows the requirements above, return True. Otherwise, return False. Example of accepted data -> return True [0, 12, 5, 60, 10, 80, 13, 35] [0, 200, 15, 120, 25, 977, 100, 3083] Example of unacceptable data -> must return False [1, 10, 25, 50, 75, 55, 4, 100, 5, 150]: time values are not defined incrementally! [0, 12, 5, 60, 5, 60, 13, 35]: duplicate time values! [0, 200, 15, 120, 25, 977, 15, 3083, 15, 3089]: duplicate time values!
PYTHON
The data is given as a list of integer with comma separated in the order
<hours> ,<weight>
(i.e. [<hours> ,<weight>,...., <hours> ,<weight>] ). This data represents the weight of the load at the given time.
For example:
l = [0, 12, 5, 60, 10, 80, 13, 35]
where 0 (l[0]), 5 (l[2]), 10 ([l[4]), 13 (l[6]) are <hours> (time values)
and 12 (l[1]), 60 (l[3]), 80 (l[5]), 35 (l[7]) are <weight> (weight load)
The data must follow specific format:
1. The time values <hours> must be defined incrementally
2. No duplicate time values
Write a function in python that checks the data to determine if the data follows the required format. If the data follows the requirements above, return True. Otherwise, return False.
Example of accepted data -> return True
[0, 12, 5, 60, 10, 80, 13, 35]
[0, 200, 15, 120, 25, 977, 100, 3083]
Example of unacceptable data -> must return False
[1, 10, 25, 50, 75, 55, 4, 100, 5, 150]: time values are not defined incrementally!
[0, 12, 5, 60, 5, 60, 13, 35]: duplicate time values!
[0, 200, 15, 120, 25, 977, 15, 3083, 15, 3089]: duplicate time values!
Step by step
Solved in 4 steps with 2 images