+ 1

Pls how do i reassign functions like addition, module and division?

13th Aug 2018, 5:21 PM
Urah Ugonna
Urah Ugonna - avatar
3 Antworten
+ 3
Please try and elaborate a bit more. What are you trying to do? What are some examples? What have you tried?
13th Aug 2018, 5:58 PM
Just A Rather Ridiculously Long Username
+ 2
With your given format, you'd have to define all the functions before assigning it to 'operation'. But what you could do is: >>> a = 4 >>> b = 7 >>> operator = '*' >>> print(eval(f'{a}{operator}{b}')) 28 Hope this helped :)
13th Aug 2018, 9:06 PM
Just A Rather Ridiculously Long Username
+ 1
def multiply(x, y): return x * y a = 4 b = 7 operation = multiply print(operation(a, b))
13th Aug 2018, 6:00 PM
Urah Ugonna
Urah Ugonna - avatar