How do i do arithmetic in python?
-
Using variables you can assign values of arithmetic equations using these operators:
+, -, *, / and others.
add = 50 + 100
subtract = 100 - 4
multiply = 102 * 0.6
divide = 220 / 4Put these in
script.py
and print them.add = 50 + 100
subtract = 100 - 4
multiply = 102 * 0.6
divide = 220 / 4print(add)
print(sutract)
print(multiply)
print(divide)gives output:
150
96
61.2
55
There's also
exponential
**
value = 10 ** 2 Is equal to 100
and
moduls (remainder)%
value = 3 % 2 Is equal to 1 (after dividing, the remainder is 1)
© Lightnetics 2024