+ 1

Python - how to count it...

HI, I'm new here so thanks for all good comments and help. I'm just after Python Tutorial, I have some ideas, but I have no practice in programming tricks yet ;) I'm thinking about function in Python which will help users to count some stuff. Here is the problem: First of all we have amount of money (Amount_A) - Defined as input We want to buy two types (or more) of things in same amount (AmountArticle_B), (AmountArticle_C) - This is what we search. Both of those things are in different price(Price_B),(Price_C) - also defined as input. Amount_A = AmountArticle_B * Price_B + AmountArticle_C * Price_C if AmountArticle_B == AmountArticle_C and AAB*PB+AAC+PC == AA Sometimes it can't be done so function should check neighbours so the number differs, on one, or two individuals etc. but we'd like them to be as close to each other as possible. I'm not awaiting final solution of pure code - just some hints what should I check and try to find it and write it by myself. Thanks for help!

23rd Nov 2017, 8:39 PM
Jakub Pełka
Jakub Pełka - avatar
6 Answers
+ 2
Something like ?: Enter variable : A Enter Price: $100 Do you want add a new item? (yes/no).
24th Nov 2017, 12:26 AM
Charles
Charles - avatar
+ 2
So you wanna sum it up?
24th Nov 2017, 12:28 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
Your question is confusing
23rd Nov 2017, 11:54 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
''' Jakub look at the *args and **kwargs feature of python functions https://pythontips.com/2013/08/04/args-and-kwargs-in-python-explained/ you can pass as many item values as you want in with it. combined with builtin sum() and a while loop it offers one solution. Look at the link below if the idea is unclear, It's just one example of a possible start to your project. https://code.sololearn.com/c5FV9v5suey9/#py '''
24th Nov 2017, 8:48 AM
richard
0
let me clear it... you have for e.g 900$ (variable) and you wonder how many items of first kind (for e.g. 14$/item - variable) and of second kind (for e.g. 33$ /item - variable) you could buy. You would like to buy same or almost same, number of items of first and second type. 900$ = x*14$ + y*33$ x=? y=? x should be equal y or very close to it. here answer is 19 it gives 893, and there is no other combination ( I suppose) to get closer.
24th Nov 2017, 5:43 AM
Jakub Pełka
Jakub Pełka - avatar
0
will check it shortly :) thanks :)
24th Nov 2017, 10:02 AM
Jakub Pełka
Jakub Pełka - avatar