Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Bartleby Related Questions Icon
Related questions
bartleby
Concept explainers
Question
python code easy way please
the one that i provide the image with code is just starting code
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()
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
Check MarkThis question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
bartleby
Step by stepSolved in 3 steps with 3 images
Knowledge Booster
Background pattern image
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
- The mouse pointer will stay on a jagged line for a long time if you keep it there for a long time.arrow_forwardPythonarrow_forwardPython Algorithms Part 1 – Binary SearchLet's play a little game to give you an idea of how different algorithms for the same problem can have wildly different efficiencies. If I choose an integer from 1 to 16 and ask you to guess what the number is, you can keep guessing numbers until you hit on it. When you guess wrong, I tell you whether you are too high or too low. Once you've guessed the number, think about the technique you used to decide each of your next guesses.If you guessed 1, then 2, then 3, then 4, and so on, until you guessed the right number, you used an approach called "linear search," meaning you guessed the numbers serially and sequentially, as if they were lined up in a row. This is definitely one way to find the mystery number, but it could require as many as 16 guesses. However, you could get lucky, if the number was 1, you’d only need 1 guess. Using a linear search process, on average, you'd need 8 guesses.There is an approach that is more efficient than just...arrow_forward
- Python: Vowel: Display a vowel selected at random.arrow_forwardVarious design methods are used to increase readability of the code.arrow_forwardCoding in python Please!!I need help please help me in the easiest way to do this coding question. Please do not post it's answer from chegg just use your own skills to write code in easyiest way possible. I will really appriciate your help. Coding language PYTHON : The purpose of this assignment is to help you get comfortable creating and using simple classes and objects. In this assignment, we wish to model a 2-D video game character’s movements. In particular, suppose we are creating a tiny game, where the character can occupy one of 25 squares, like so: The first thing we need to keep track of is the character’s name, so we can differentiate this character from other characters or enemies. The other thing we need to keep track of is the character’s position, i.e., which square they are in. In order to do this, we’ll use an X-Y coordinate system with the origin in the top left corner (the 0,0 square in the picture). So, in the picture, the character occupies square 3, 2;...arrow_forward
- OpenGL Programming Help (please provide a screenshot that it works) Write a program that creates a three-dimensional figure of the University logo "IU" that animates. The In response to the menu selection, one of the two letters will spin about a vertical axis. When the user clicks on the right mouse button and selects the menu option to spin the "U", the "I" should stop spinning and the "U" should spin in the same manner. At no point should both letters spin at the same time. This should use a display listarrow_forwardJavaProblem 2-1 Random Number ProblemBuild an application where each time a button is clicked, a random number from 1 to 100 is displayed in a textField.arrow_forwardWhat happens when you move the mouse cursor over a squiggly line in the code editor?arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education