Feb-01-2018, 03:05 PM
Hey everyone! I just started programming in Python some weeks ago and I'm stuck with some homework.
We are asked to create a calculator which could add, subtract, multiply and divide but we are just allowed to use additions. That means, no -, * o : sign. Plus, we cannot use operations provided by the programming language (the operator for example). However, we are allowed to use an increment operator (++), and logical operators.
For now, I've been able to make the addition part (the most obvious...) but I don't know where to start for the others, especially for the divide and subtract parts. For the multiplying, I thought about doing a function that sums a number x times. For example, 5*4 is 5+5+5+5.
Well, if someone could give me a hint (without doing it for me, obviously, we are here to learn!) that would help me!
Thanks a lot,
Gérard
We are asked to create a calculator which could add, subtract, multiply and divide but we are just allowed to use additions. That means, no -, * o : sign. Plus, we cannot use operations provided by the programming language (the operator for example). However, we are allowed to use an increment operator (++), and logical operators.
For now, I've been able to make the addition part (the most obvious...) but I don't know where to start for the others, especially for the divide and subtract parts. For the multiplying, I thought about doing a function that sums a number x times. For example, 5*4 is 5+5+5+5.
Well, if someone could give me a hint (without doing it for me, obviously, we are here to learn!) that would help me!
Thanks a lot,
Gérard