How to use arithmetic operators as functions in Python

1 Answer

0 votes
from operator import *

a = 5
b = 2    


print('add(a, b):', add(a, b))     
print('sub(a, b):', sub(a, b))     

print('floordiv(a, b):', floordiv(a, b))     
print('truediv(a, b):', truediv(a, b))  

print('mod(a, b):', mod(a, b))     
print('mul(a, b):', mul(a, b))     

print('pow(a, b):', pow(a, b))     
   




'''
run:

add(a, b): 7
sub(a, b): 3
floordiv(a, b): 2
truediv(a, b): 2.5
mod(a, b): 1
mul(a, b): 10
pow(a, b): 25

'''

 



answered May 30, 2019 by avibootz

Related questions

1 answer 165 views
1 answer 163 views
1 answer 153 views
1 answer 177 views
1 answer 113 views
113 views asked Oct 11, 2022 by avibootz
1 answer 162 views
162 views asked Jan 9, 2016 by avibootz
...