You are browsing as a guest. Sign up (or log in) to start making projects!

Open comments for this post

3h 34m 5s logged

Min/Max function

Made a new function that finds the minimum and maximum of the data.

How it works

  1. The program asks the user to type 0 or 1 for min/max
  2. The program uses a for loop and goes through each row finding the maximum and minimum or what the user chose.
  3. In each cell in the sheet, the program checks if that cell is less/greater than the current min/max using the min()/max() function.
  4. The function then returns a tuple of the price of the product that was the min/max and the name of that product.
  5. The result is printed using a formatted string.

Debugging

While creating the function, there was some errors with the if statement.

  • The if statement checks if the user typed 0 or 1, but the user input was not converted into an int. So the min max function was skipped.

  • The function started to return the minimum price but the name of that product was different.

  • The fix was simple - there was an if statement that checked if the min/max was the current cell but the part where it assigns the product_name was not indented, so it was out of this if statement

  • Had a few errors with unpacking, but the changes were made to fix it

0
1

Comments 0

No comments yet. Be the first!