#Save the below code as python file and execute to see output.
varA = 15
varB = 6
# 1. Addition operator
add_sample = varA + varB
print(add_sample)
# 2. Subtract operator
sub_sample = varA - varB
print(sub_sample)
# 3. Multiply operator
multiply_sample = varA * varB
print(multiply_sample)
# 4. Division operator
division_sample = varA / varB
print(division_sample)
#5. Add Assignment (usefull for loop statement, any one below method can be used)
add_sample += 3
print(add_sample)
add_sample = add_sample + 1
print(add_sample)
# Similarly for other operators, use operator sign befor equal to assign value:
# examples: -=, *=, /=
#7 Modulus
mod_sample = varA % varB
print(mod_sample)
#8 exponentiation
exp_sample = varA ** 2
print(exp_sample)
# Note: Operator Rule
# BODMAS: Bracket Orders Division Multiple Addition Subtraction
varA = 15
varB = 6
# 1. Addition operator
add_sample = varA + varB
print(add_sample)
# 2. Subtract operator
sub_sample = varA - varB
print(sub_sample)
# 3. Multiply operator
multiply_sample = varA * varB
print(multiply_sample)
# 4. Division operator
division_sample = varA / varB
print(division_sample)
#5. Add Assignment (usefull for loop statement, any one below method can be used)
add_sample += 3
print(add_sample)
add_sample = add_sample + 1
print(add_sample)
# Similarly for other operators, use operator sign befor equal to assign value:
# examples: -=, *=, /=
#7 Modulus
mod_sample = varA % varB
print(mod_sample)
#8 exponentiation
exp_sample = varA ** 2
print(exp_sample)
# Note: Operator Rule
# BODMAS: Bracket Orders Division Multiple Addition Subtraction
No comments:
Post a Comment