python - Writing a function that takes two integers and outputs the result of different applied operators -


first post here. have started learn python , have been trying solve menial task 2 hours now, searches included.

what wish write function take 2 arguments (integers) , gives result of classic 4 operators. show have done far, , not acceptable solution did find.

first attempt, getting first return value

def classicoperations(a, b): return + b return * b return / b return - b  print "let's use 4 classic operations"  print classicoperations(53, 100) 

on other hand, using print seems work quite well

def classicoperations(a, b): print + b print * b print / b print - b  print "let's use 4 classic operations 1 more time"  classicoperations(5, 100) 

how prefer end result, reason cannot work , not sure why.

while print makes program lose information, cannot seem make function "return" keep track of 4 different values nor how separete them a combined string. help, link kind of understanding lacking appreciated.

def classicoperations(a, b): print "adding" "to" b "be create total of" a+b  classicoperations(234324, 34324) 

a return statement stops execution of function. if want return multiple values, 1 return:

return a+b, a-b, a*b, a/b 

this creates , returns tuple of 4 values.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -