Professional Documents
Culture Documents
Arithmetic operators
Arithmetic operators are used to perform mathematical operations like
addition, subtraction, multiplication, etc.
Operato
Meaning Example
r
/ Divide left operand by the right one (always results into float) x/y
x % y (remainder of
% Modulus - remainder of the division of left operand by the right
x/y)
Floor division - division that results into whole number adjusted to the left in
// x // y
the number line
input( )
print()
Example 3-
a = 5
b = 6
c = 7
example 4
Example 6
num = 12
else:
print(num,"is not a prime number")
rows = 5
for i in range(0, rows + 1):
for j in range(rows - i, 0, -1):
print(j, end=' ')
print()
Example- int
num = 10
# check and print type of num variable
print(type(num))
Function example
def pri_Twice(bruce):
print(bruce, bruce)
pri_Twice('Spam')
pri_Twice(5)
pri_Twice(3.14159)
pri_Twice('Spam'*4)