Add the code to the end of your monitorLevels() method. It must become the last code of monitorLevels(). Study the comments and complete the code # Loop through displayList for i in range(0,len(displayList)): # Test if the first item in the current sub-list contains the text "Price Level" # Tip: Remember that each sub-list is a list within a list (displayList). So you have # to access its items via displayList followed by TWO indexes. . . . # Extract the second item from the current sub-list into a variable called priceLevel priceLevel = . . . # Test if priceLevel is between previousPrice and currentPrice OR # priceLevel == previousPrice OR # priceLevel == currentPrice if( . . . ): # Sound the alarm. Pass in the frequency and duration. if self.currentPrice > self.previousPrice: frequency = 800 duration = 700 else: frequency = 400 duration = 700 winsound.Beep(frequency, duration) # Print the text 'Alarm' with a green background colour, so that the user # can go back into the historical data to see what prices raised the alarm.
Add the code to the end of your monitorLevels() method. It must become the last code of monitorLevels().
Study the comments and complete the code
# Loop through displayList
for i in range(0,len(displayList)):
# Test if the first item in the current sub-list contains the text "Price Level"
# Tip: Remember that each sub-list is a list within a list (displayList). So you have
# to access its items via displayList followed by TWO indexes.
. . .
# Extract the second item from the current sub-list into a variable called priceLevel
priceLevel = . . .
# Test if priceLevel is between previousPrice and currentPrice OR
# priceLevel == previousPrice OR
# priceLevel == currentPrice
if(
. . .
):
# Sound the alarm. Pass in the frequency and duration.
if self.currentPrice > self.previousPrice:
frequency = 800
duration = 700
else:
frequency = 400
duration = 700
winsound.Beep(frequency, duration)
# Print the text 'Alarm' with a green background colour, so that the user
# can go back into the historical data to see what prices raised the alarm.
. . .
Step by step
Solved in 2 steps with 1 images