0
How can i do a maths operation? Like the description. And i don't understand the "%" concept.
i dont know how to do maths operations like "2+4" "7/3". pls examples. thanks :))!!
4 odpowiedzi
+ 11
#its very simple you'll find!
print(2+4)
print(7/3)
print(2%4)
# and % is the remainder of division of two numbers. inside a string it can do other things, but that's unrelated to your question
+ 2
4+2 = 6 (Normal adding process)
7/3 = 2.333333333... (Normal Division process)
If we divide 1.25 by .5 than, we can write:
1.25= .5*2(here .5*2=1)+.25 (here
.25 is remainder, here further division approaches not followed as normal mathematical process follows, in normal mathematical process, we can write 1.25/.5 = 2.5)
hence,
1.25 divided by .5, quotient is 2 and .25 isn't divided by .5 so it is remainder.
above term is expressed by modulus sign (%),where % shows only remainder,not shows quotient.
it is expressed by
5%2 = 1
11%4 = 3
5%3 = 2
3%5 = 3
6%5 = 1
12%7 = 5
2%2 = 0
1.25%.5 = .25
+ 1
This can help as well. Also gives list of operators.
https://www.digitalocean.com/community/tutorials/how-to-do-math-in-JUMP_LINK__&&__python__&&__JUMP_LINK-3-with-operators
+ 1
Ok thank you very much!!!! You're the best.