python code easy way please the one that i provide the image with code is just starting code

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

python code easy way please
the one that i provide the image with code is just starting code

import pytest
from typing import List
# Accepts a list of integers
def initializeMinMaxList (myList: List[int]) -> None:
myList.sort()
# given
def insertItem(myList: List[int], item: int) -> None: # given
myList.append (item)
myList.sort()
def getMinMax (myList: List[int], minormax: str) -> int:
assert minormax.upper()=="MAX" or minormax.upper()=="MIN", "2nd argument must be 'Min' or 'Max' "
result: int
if minormax == "MAX":
# given -- but requires additional assert
result - myList[-1]
del mylist[-1]
else:
result = myList[0]
del mylist[0]
return result
# Main function is given.
def main():
alist = [10, 11, 99, 1, 55, 100, 34, 88]
print("Starting List: ", alist)
initializeMinMaxList (alist)
mini = getMinMax(alist, "MIN")
print("1st min: %d" % (min1))
min2 = getMinMax(alist, "MIN")
print("2nd min: %d" % (min2))
max1 = getMinMax (alist, "MAX")
print("1st max: %d" % (max1))
max2 = getMinMax (alist, "MAX")
print("2nd max: %d" % (max2))
print("Insert %d %d %d %d" % (min1 - 1, min2 - 1, max1 + 1, max2 + 1))
insertItem(alist, mini -
insertItem(alist, min2 - 1)
insertItem(alist, max1 + 1)
insertItem(alist, max2 + 1)
1)
mini = getMinMax (alist, "MIN")
print("1st min: %d" % (min1))
min2 = getMinMax(alist, "MIN")
print("2nd min: %d" % (min2))
max1 = getMinMax (alist, "MAX")
print("1st max: %d" % (max1))
max2 = getMinMax(alist, "MAX")
print("2nd max: %d" % (max2))
print("DONE. Please Enter to exit.")
input()
if
name
_main_":
main()
Transcribed Image Text:import pytest from typing import List # Accepts a list of integers def initializeMinMaxList (myList: List[int]) -> None: myList.sort() # given def insertItem(myList: List[int], item: int) -> None: # given myList.append (item) myList.sort() def getMinMax (myList: List[int], minormax: str) -> int: assert minormax.upper()=="MAX" or minormax.upper()=="MIN", "2nd argument must be 'Min' or 'Max' " result: int if minormax == "MAX": # given -- but requires additional assert result - myList[-1] del mylist[-1] else: result = myList[0] del mylist[0] return result # Main function is given. def main(): alist = [10, 11, 99, 1, 55, 100, 34, 88] print("Starting List: ", alist) initializeMinMaxList (alist) mini = getMinMax(alist, "MIN") print("1st min: %d" % (min1)) min2 = getMinMax(alist, "MIN") print("2nd min: %d" % (min2)) max1 = getMinMax (alist, "MAX") print("1st max: %d" % (max1)) max2 = getMinMax (alist, "MAX") print("2nd max: %d" % (max2)) print("Insert %d %d %d %d" % (min1 - 1, min2 - 1, max1 + 1, max2 + 1)) insertItem(alist, mini - insertItem(alist, min2 - 1) insertItem(alist, max1 + 1) insertItem(alist, max2 + 1) 1) mini = getMinMax (alist, "MIN") print("1st min: %d" % (min1)) min2 = getMinMax(alist, "MIN") print("2nd min: %d" % (min2)) max1 = getMinMax (alist, "MAX") print("1st max: %d" % (max1)) max2 = getMinMax(alist, "MAX") print("2nd max: %d" % (max2)) print("DONE. Please Enter to exit.") input() if name _main_": main()
(1) def test_getMinMaxCasel():
This function will test a standard use case for our MinMaxList.
(a) Create a list with two items that are different.
(b) Call initializeMinMaxlist() with (a).
(c) Use getMinMax () to get the mimimum item. Use an assert statement to check if this is correct. Error
message should be "Min should be x", where x is the minimum item in the list specified in (a).
(d) Use getMinMax() to get the maximum item. Use an assert statement to check if this is correct. Error
message should be "Max should be y", where y is the maximum item in the list specified in (a).
(2) def test_getMinMaxCase2():
This function will test an edge case where the list only has a single item.
(a) Create a list with only 1 item, let's call this item y.
(b) Call initializeMinMaxlist() with (a).
(c) Use getMinMax() to get the minimum item (which is y). Use an assert statement to check if this is correct.
Error message should be "Min should be y", where y is the single item in your list in (a).
(d) Use insertItem() to insert the same item y back into the list in (a).
(e) Use getMinMax () to get the maximum item (which is y). Use an assert statement to check if this is correct.
Error message should be "Max should be y", where y is the maximum item in the list specified in (a).
(3) def test_getMinMaxCase3():
This function will test an edge case where the list starts out empty.
(a) Create an empty list.
(b) Call initializeMinMaxlist() with (a).
(c) Insert an item x into (a) using insertItem().
(d) Insert an item y into (a) using insertItem(). Item y should be larger than x.
(e) Use getMinMax () to get the minimum item. Use an assert statement to check if this is correct.
Error message should be "Min should be x", where x is the minimum item inserted into (a).
(f) Use getMinMax () to get the maximum item. Use an assert statement to check if this is correct.
Error message should be "Max should be y", where y is the maximum item inserted into (a).
(4) def test_getMinMaxRequestError()
This function will test to see if getMinMax() properly causes an assertion error when the string argument is not correct.
(a) Create a list
(b) Call initializeMinMa
(c) Call getMinMax() with a, but using "MID" instead of "MIN" or "MAX". This will cause getMinMax () to raise an AssertionError.
with 3 items.
) with (a).
(d) Check if the AssertionError was raised. Assert on this condition, if the condition was not rasied, your error should be:
"Should ralse AssertionError!"
Continues on next page.
Page 4/9
(5) def test_getMinMaxEmptyError ():
This function will test to see if getMinMax() properly causes an assertion error when the list is empty.
(a) Create an empty list.
(b) Call initializeMinMaxlist() with (a).
(c) Call getMinMax(). If you did Task 1 correctly, this will cause getMinMax () to raise an AssertionError.
(d) Check if the AssertionError was raised. Assert on this condition, if the condition was not rasie, your error should be:
"Should raise AssertionError!"
Transcribed Image Text:(1) def test_getMinMaxCasel(): This function will test a standard use case for our MinMaxList. (a) Create a list with two items that are different. (b) Call initializeMinMaxlist() with (a). (c) Use getMinMax () to get the mimimum item. Use an assert statement to check if this is correct. Error message should be "Min should be x", where x is the minimum item in the list specified in (a). (d) Use getMinMax() to get the maximum item. Use an assert statement to check if this is correct. Error message should be "Max should be y", where y is the maximum item in the list specified in (a). (2) def test_getMinMaxCase2(): This function will test an edge case where the list only has a single item. (a) Create a list with only 1 item, let's call this item y. (b) Call initializeMinMaxlist() with (a). (c) Use getMinMax() to get the minimum item (which is y). Use an assert statement to check if this is correct. Error message should be "Min should be y", where y is the single item in your list in (a). (d) Use insertItem() to insert the same item y back into the list in (a). (e) Use getMinMax () to get the maximum item (which is y). Use an assert statement to check if this is correct. Error message should be "Max should be y", where y is the maximum item in the list specified in (a). (3) def test_getMinMaxCase3(): This function will test an edge case where the list starts out empty. (a) Create an empty list. (b) Call initializeMinMaxlist() with (a). (c) Insert an item x into (a) using insertItem(). (d) Insert an item y into (a) using insertItem(). Item y should be larger than x. (e) Use getMinMax () to get the minimum item. Use an assert statement to check if this is correct. Error message should be "Min should be x", where x is the minimum item inserted into (a). (f) Use getMinMax () to get the maximum item. Use an assert statement to check if this is correct. Error message should be "Max should be y", where y is the maximum item inserted into (a). (4) def test_getMinMaxRequestError() This function will test to see if getMinMax() properly causes an assertion error when the string argument is not correct. (a) Create a list (b) Call initializeMinMa (c) Call getMinMax() with a, but using "MID" instead of "MIN" or "MAX". This will cause getMinMax () to raise an AssertionError. with 3 items. ) with (a). (d) Check if the AssertionError was raised. Assert on this condition, if the condition was not rasied, your error should be: "Should ralse AssertionError!" Continues on next page. Page 4/9 (5) def test_getMinMaxEmptyError (): This function will test to see if getMinMax() properly causes an assertion error when the list is empty. (a) Create an empty list. (b) Call initializeMinMaxlist() with (a). (c) Call getMinMax(). If you did Task 1 correctly, this will cause getMinMax () to raise an AssertionError. (d) Check if the AssertionError was raised. Assert on this condition, if the condition was not rasie, your error should be: "Should raise AssertionError!"
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Rendering
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education