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

Excel-Price-Processor

  • 4 Devlogs
  • 5 Total hours

A python program that can automatically add a percent discount column to an excel file

Ship #1 Changes requested

This program runs through an excel file that has a products with prices and creates a new column with a discount. It can also find the minimum and maximum of the products. In this product I learned about classes and unpacking in python. It was a challenge to debug, but most of the time the errors were value errors. I learned how to use github more properly too.

  • 4 devlogs
  • 5h
Try project → See source code →
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

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

Replying to @jonathanrobin13

0
1
Open comments for this post

28m 35s logged

Now users can type in letters that represent each column instead of typing numbers

Now users can type in letters that represent each column instead of typing numbers

Replying to @jonathanrobin13

0
1

Followers

Loading…