Welcome to the forums.
Do you have any code to post/what have you written so far?
Is there a specific lesson that this Q is attached to?
this is task. i know any integer numers to change float like 13 / 1 = 13.0
but i need reverse. how?
Without a built-in method you’d have to build a function yourself to do this to replicate the functionality of the method you’re trying to avoid.
You might have to get clever about using some deeper tools to get it done (but it’s too vague to know just from the prompt, this is either an advanced exercise or a simple one). Or conversely, it could just be a thought exercise if it’s particularly no “float methods” but if you could use other built-in methods this simplifies it greatly.
i know solution is simple .%, /, // i have to use this operators. and i do not know how…
Ok so it’s just a mathematical issue then, it’s a matter of working out the algebra. Just start from the fact that any integer is some
n * d where both n and d are integers. It follows that
d divides k and so forth.
show example if u know
The idea of the forum is to be constructive instead of giving answers, feel free to show some attempts at your work and we can provide feedback!
Programming involves a lot of discrete and number theory problems, so working it out (even if wrong) is really a big part of the battle.
But as an example of the previous one:
6 is an int it can also be represented as 2 x 3 or 1 x 6
As a reminder the modulo operator shows the remainder that would happen in division
i tried a lot but i can not find
That’s ok! show us some work and thought process, we can nudge it towards the answer.
One more hint:
>>> 2 == 2.0 True
look i know methods like int(), round(), math.floor(), math.trunc(). but in this case i can not use methods
Yes but have you tried manipulating numbers to build it up without methods?
The 2 hints currently are:
- division can be expressed as multiplication
- you can compare a float to an int and have it check for equality
Try using these 2 hints to do something and if it doesn’t work let us know (show us how you get stuck with this idea)
random float number is 13.0. every time i use every operator the results type ise float. but i need integer.
Considering you know the integer factors that build up to thirteen, is there a way you can write a function that collects these? (think about it, try it)
Written more generally, you have your original number x and it’s an int, you know a and b are factors that divide it perfectly and you can check them against integers.
For inspiration maybe look up how simple is_prime function checks are done.
i know what u mean. but it is not answer with ==.
Are you sure? There can be more than one answer. I can think of one with
Have you considered using loops?
i know loops but my team is new and loop is not permit use because our loop lesson after 1 month. thanks a lot