While I was trying to learn python by doing it. I created a really primitive app, called best buy. You can find it here:
Here is what this code suppossed to do:
*You add products with its name, price and rating:
Note : Rating defines liking ratio. For example, rating 2, means you like that product two times then product with rating 1. If difference of your liking of two items are not that big, you can put numbers like 7,8 indicating a minor difference in liking.
*You add budget
*Program will (try) to calculate best bundle of products you can get. Like this;
a:5 b:7 c:4 → You should buy 5 piece of a, 7 piece of b, 4 piece of c
And that’s all, there is also functions to remove product and list product.
How to use
After downloading the program (which is only 2.6 KB!), extract it to somewhere. Run cli.py. You will see a command prompt. First at least two products like this:
add product car 5 7
This will add product, named car, with price 5 and rating 7
Then add another one in the same way. After that, you can enter your budget like this:
add budget 100
This will add your budget. Then you can calculate what to buy with:
You can keep adding, removing products, or change your budget as many times as you like. Other command you can use:
quit → quits
help → gives possible commands
remove product [insert name of a product here] → removes product
list products → gives a list of products.
list budget → shows your current budget
Known bugs: Because products assumed to be un-divideable, flooring optimum number to integer causes unspent budget. Will fix this later.
What I want to hear from you:
Since purpose of this is code to learn python. I want to hear from you
- Better practices: How can I write this code in a better way.
- Comments on comments : How do you think I used my comments. How can I better comment.
- **Object orientation: ** What do you think of my object orientation, can I make it in a better way?
- **Style: ** What do you think of my coding style, as in spaces, line breaks, upper-lower cases etc.
And any additional comment is welcome.