Yes, KTurtle will do your math. You can add (+), substract (-), multiply (*), and divide (/). Here is an example in which we use all of them:
a = 20 - 5 b = 15 * 2 c = 30 / 30 d = 1 + 1 print "a: "+a+", b: "+b+", c: "+c+", d: "+dDo you know what value a, b, c and d have? Please note the use of the assignment symbol
=
.If you just want a simple calculation to be done you can do something like this:
print 2004-12
Now an example with parentheses:
print ( ( 20 - 5 ) * 2 / 30 ) + 1The expressions inside parentheses will be calculated first. In this example, 20-5 will be calculated, then multiplied by 2, divided by 30, and then 1 is added (giving 2).
Would you like to make a comment or contribute an update to this page?
Send feedback to the KDE Docs Team